当前位置: 首页>>代码示例>>Java>>正文


Java Helper类代码示例

本文整理汇总了Java中com.github.jknack.handlebars.Helper的典型用法代码示例。如果您正苦于以下问题:Java Helper类的具体用法?Java Helper怎么用?Java Helper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Helper类属于com.github.jknack.handlebars包,在下文中一共展示了Helper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handlebars

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
@Bean
public ViewResolver handlebars() {
    HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
    
    // add handlebars helper to get a label's literal without datatype
    viewResolver.registerHelper("literal", new Helper<Literal>() {
        @Override
        public Object apply(Literal literal, Options options) throws IOException {
            return literal.getLabel();
        }
    });
    
    viewResolver.setPrefix("/WEB-INF/templates/");
    viewResolver.setSuffix(".hbs");
    viewResolver.setFailOnMissingFile(false);
    
    return viewResolver;
}
 
开发者ID:DTL-FAIRData,项目名称:FAIRDataPoint,代码行数:19,代码来源:RestApiContext.java

示例2: dateHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<Long> dateHelper() {
    return new Helper<Long>() {
        public CharSequence apply(Long arg0, Options arg1) throws IOException {
            PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendDays()
                .appendSuffix(" d : ")
                .appendHours()
                .appendSuffix(" h : ")
                .appendMinutes()
                .appendSuffix(" m : ")
                .appendSeconds()
                .appendSuffix(" s : ")
                .appendMillis()
                .appendSuffix(" ms")
                .toFormatter();
            return formatter.print(new Period((arg0 * 1) / 1000000));
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:20,代码来源:Helpers.java

示例3: TemplateCaptureTarget

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
public TemplateCaptureTarget (File baseDir,
                              String indexTemplate,
                              String indexMoreTemplate,
                              String headerTemplate,
                              String footerTemplate,
                              String entryTemplate) {
    this.baseDir = baseDir;
    if (!baseDir.exists() && !baseDir.mkdirs()) {
        throw new IllegalArgumentException("baseDir does not exist and could not be created: "+baseDir.getAbsolutePath());
    }

    final Handlebars handlebars = new Handlebars(new ClassPathTemplateLoader("/"));
    handlebars.registerHelper("nl2br", new Helper<Object>() {
        public CharSequence apply(Object src, Options options) {
            return src == null || src.toString().isEmpty() ? "" : new Handlebars.SafeString(src.toString().replace("\n", "<br/>"));
        }
    });

    this.indexTemplate = compileOrDie(indexTemplate, handlebars);
    this.indexMoreTemplate = compileOrDie(indexMoreTemplate, handlebars);
    this.headerTemplate = compileOrDie(headerTemplate, handlebars);
    this.footerTemplate = compileOrDie(footerTemplate, handlebars);
    this.entryTemplate = compileOrDie(entryTemplate, handlebars);
}
 
开发者ID:cobbzilla,项目名称:restex,代码行数:25,代码来源:TemplateCaptureTarget.java

示例4: embeddingHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<String> embeddingHelper() {
    return new Helper<String>() {
        @Override
        public CharSequence apply(String arg0, Options arg1) throws IOException {
            String toReturn;
            String id = UUID.randomUUID().toString();
            int index = arg1.param(1);
            if (arg1.param(0).toString().contains("image")) {
                toReturn =
                    "<button 'type='button'"
                        + "class='btn btn-primary'"
                        + "data-toggle='modal' "
                        + "data-target='#" + id + "'>"
                        + "  Screenshot " + ++index + ""
                        + "</button>";
                toReturn +=
                    "<div id='" + id + "'"
                        + "class='modal fade'"
                        + "tabindex='-1'"
                        + "role='dialog'"
                        + "aria-labelledby='myModalLabel'"
                        + "aria-hidden='true'>"
                        + "  <div style='width:90%;height:90%;'"
                        + "  class='modal-dialog'>"
                        + "    <div class='modal-content'>"
                        + "      <div class='modal-body'>"
                        + "        <img "
                        + "        src='data:image/png;base64," + arg0 + "'"
                        + "        class='img-responsive'>"
                        + "      </div>"
                        + "    </div>"
                        + "  </div>"
                        + "</div>";
            } else {
                toReturn = "<pre>" + arg0 + "</pre>";
            }
            return toReturn;
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:41,代码来源:Helpers.java

示例5: resultColorHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<String> resultColorHelper() {
    return new Helper<String>() {
        @Override
        public CharSequence apply(String arg0, Options arg1) throws IOException {
            return checkState(
                arg0.toLowerCase(),
                Constants.INFO,
                Constants.SUCCESS,
                Constants.DANGER,
                Constants.WARNING);
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:14,代码来源:Helpers.java

示例6: resolveTitleHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<String> resolveTitleHelper() {
    return new Helper<String>() {
        @Override
        public CharSequence apply(String arg0, Options arg1) throws IOException {
            return checkState(
                arg0.toLowerCase(),
                Constants.THIS_STEP_HAS_BEEN_SKIPPED,
                Constants.THIS_STEP_HAS_PASSED,
                Constants.THIS_STEP_HAS_FAILED,
                Constants.THIS_STEP_HAS_NOT_BEEN_DEFINED);
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:14,代码来源:Helpers.java

示例7: isCollapsedHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<String> isCollapsedHelper() {
    return new Helper<String>() {
        @Override
        public CharSequence apply(String arg0, Options arg1) throws IOException {
            return checkState(
                arg0.toLowerCase(),
                Constants.COLLAPSE_IN,
                Constants.COLLAPSE,
                Constants.COLLAPSE_IN,
                Constants.COLLAPSE_IN);
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:14,代码来源:Helpers.java

示例8: nowHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<Object> nowHelper() {
    return new Helper<Object>() {
        @Override
        public CharSequence apply(Object context, Options options) throws IOException {
            Calendar cal = Calendar.getInstance();
            Date date = cal.getTime();
            String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(date);
            TimeZone tz = cal.getTimeZone();
            return now + " " + tz.getID();
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:13,代码来源:Helpers.java

示例9: doTableHelperForStep

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<List<StepRow>> doTableHelperForStep() {
    return new Helper<List<StepRow>>() {
        @Override
        public CharSequence apply(List<StepRow> rows, Options arg1) throws IOException {
            String tableContent = "<table  class='table table-condensed table-hover'>";
            int indexRow = 0;
            for (StepRow row : rows) {
                indexRow++;
                if (indexRow == 1) {
                    tableContent += "<thead><tr>";
                } else if (indexRow == 2) {
                    tableContent += "<tbody><tr>";
                } else {
                    tableContent += "<tr>";
                }
                for (String cell : row.getCells()) {
                    if (indexRow == 1) {
                        tableContent += "<th>" + cell + "</th>";
                    } else {
                        tableContent += "<td>" + cell + "</td>";
                    }
                }
                if (indexRow == 1) {
                    tableContent += "</tr></thead>";
                } else {
                    tableContent += "</tr>";
                }
            }
            tableContent += "</tbody></table>";
            return tableContent;
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:34,代码来源:Helpers.java

示例10: doTableHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Helper<List<Row>> doTableHelper() {
    return new Helper<List<Row>>() {
        @Override
        public CharSequence apply(List<Row> rows, Options arg1) throws IOException {
            String tableContent = "<table  class='table table-condensed table-hover'>";
            int indexRow = 0;
            for (Row row : rows) {
                indexRow++;
                if (indexRow == 1) {
                    tableContent += "<thead><tr>";
                } else if (indexRow == 2) {
                    tableContent += "<tbody><tr>";
                } else {
                    tableContent += "<tr>";
                }
                for (String cell : row.getCells()) {
                    if (indexRow == 1) {
                        tableContent += "<th>" + cell + "</th>";
                    } else {
                        tableContent += "<td>" + cell + "</td>";
                    }
                }
                if (indexRow == 1) {
                    tableContent += "</tr></thead>";
                } else {
                    tableContent += "</tr>";
                }
            }
            tableContent += "</tbody></table>";
            return tableContent;
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:34,代码来源:Helpers.java

示例11: loadHandleBars

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
private Handlebars loadHandleBars(final I18n i18n) {
    Handlebars handlebars = new Handlebars()
            .with(cache);

    handlebars.registerHelper("t", new Helper<Object>() {
        @Override
        public CharSequence apply(final Object context, final Options options) {
            String key = options.param(0);
            return i18n.t(key);
        }
    });

    return handlebars;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:15,代码来源:PASystemImpl.java

示例12: setup

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
@Setup
public void setup() throws IOException {
  template = new com.github.jknack.handlebars.Handlebars(new ClassPathTemplateLoader("/", ".html"))
          .registerHelper("minus", new Helper<Stock>() {
            @Override
            public CharSequence apply(final Stock stock, final Options options)
                throws IOException {
              return stock.getChange() < 0 ? new SafeString("class=\"minus\"") : null;
            }
          }).compile("templates/stocks.hbs");
  this.context = getContext();
}
 
开发者ID:mbosecke,项目名称:template-benchmark,代码行数:13,代码来源:Handlebars.java

示例13: registerHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <H> HelperRegistry registerHelper(final String name, final Helper<H> helper) {
    Helper<?> oldHelper = helpers.put(name, helper);
    if (oldHelper != null) {
        logger.warn("Helper '{}' has been replaced by '{}'", name, helper);
    }
    return this;
}
 
开发者ID:wso2-attic,项目名称:carbon-uuf,代码行数:12,代码来源:RuntimeHelperRegistry.java

示例14: registerHelpers

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * This will register only the class source of enum with {@link Helper} implementation.
 */
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public HelperRegistry registerHelpers(final Class<?> helperSource) {
    if (!Enum.class.isAssignableFrom(helperSource)) {
        throw new UnsupportedOperationException();
    }
    Enum[] helpers = ((Class<Enum>) helperSource).getEnumConstants();
    for (Enum helper : helpers) {
        registerHelper(helper.name(), (Helper) helper);
    }
    return this;
}
 
开发者ID:wso2-attic,项目名称:carbon-uuf,代码行数:18,代码来源:RuntimeHelperRegistry.java

示例15: lowerCaseHelper

import com.github.jknack.handlebars.Helper; //导入依赖的package包/类
public static Helper<Object> lowerCaseHelper() {
  return new Helper<Object>() {

    @Override
    public CharSequence apply(Object s, Options options) throws IOException {
      if (s != null) {
        return s.toString().toLowerCase();
      }
      return "";
    }
  };
}
 
开发者ID:adrobisch,项目名称:raml-converter,代码行数:13,代码来源:HandlebarsHelpers.java


注:本文中的com.github.jknack.handlebars.Helper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。