All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rythm.~table.html Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version

@import act.util.DataTable, org.osgl.Lang, org.osgl.util.S
@args DataTable table

  @for(table.heading()) {
  
  }
  
  @def boolean isUrl(Object v) {
    if (null == v) {return false;}
    if (!(v instanceof String) && !(v instanceof Appendable)) {
      return false;
    }
    String s = v.toString();
    return s.startsWith("http://") || s.startsWith("https://");
  }
  @def String addHtmlTableAccept(Object v) {
    if (null == v) return "";
    String url = v.toString();
    return url + (url.contains("?") ? "&" : "?") + "_accept=htmltable";
  }
  @def String toString(Object v) {
    if (null == v) return "";
    if (!Lang.isSimpleType(v.getClass())) {
      String s = com.alibaba.fastjson.JSON.toJSONString(v, true);
      s = S.strip(s).of(S.DOUBLE_QUOTES);
  return "
" + s + "
"; } return v.toString(); } @for(Object row: table) { @for(String label: table.heading()) { } }
@_
@{ Object v = table.val(row, label) } @if(isUrl(v)) { @v } else { @toString(v).raw() }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy