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


Java ClassPathTemplateLoader类代码示例

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


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

示例1: start

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
  TemplateLoader loader = new ClassPathTemplateLoader(TEMPLATE_DIR);
  StarterService starter = new StarterService(vertx, tempDir());
  ProjectGeneratorService generator = new ProjectGeneratorService(vertx, new TemplateService(vertx, loader));
  ArchiveService archive = new ArchiveService(vertx);

  vertx.eventBus().<JsonObject>consumer("project.requested").handler(starter::starter);
  vertx.eventBus().<JsonObject>consumer("generate").handler(generator::generate);
  vertx.eventBus().<JsonObject>consumer("archive").handler(archive::archive);
  vertx.eventBus().<JsonObject>consumer("project.created").handler(starter::clean);

  log.info("\n----------------------------------------------------------\n\t" +
      "{} is running!\n" +
      "----------------------------------------------------------",
    GeneratorVerticle.class.getSimpleName());
  startFuture.complete();
}
 
开发者ID:vert-x3,项目名称:vertx-starter,代码行数:19,代码来源:GeneratorVerticle.java

示例2: start

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
    TemplateLoader loader = new ClassPathTemplateLoader(TEMPLATE_DIR);
    ForgeService forge = new ForgeService(vertx, tempDir());
    ProjectGeneratorService generator = new ProjectGeneratorService(vertx, new TemplateService(loader));
    ArchiveService archive = new ArchiveService(vertx);

    vertx.eventBus().<JsonObject>consumer("forge.forge").handler(forge::forge);
    vertx.eventBus().<JsonObject>consumer("forge.clean").handler(forge::clean);
    vertx.eventBus().<JsonObject>consumer("generate").handler(generator::generate);
    vertx.eventBus().<JsonObject>consumer("archive").handler(archive::archive);

    log.info("\n----------------------------------------------------------\n\t" +
            "{} is running!\n" +
            "----------------------------------------------------------",
        GeneratorVerticle.class.getSimpleName());
    startFuture.complete();
}
 
开发者ID:danielpetisme,项目名称:vertx-forge,代码行数:19,代码来源:GeneratorVerticle.java

示例3: TemplateCaptureTarget

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的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: parseTemplateUrl

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
public static TemplatePath parseTemplateUrl(String templatePath) throws GenerateException {
    if (templatePath == null) {
        return null;
    }
    TemplatePath tp;
    if (templatePath.startsWith(CLASSPATH)) {
        String resPath = templatePath.substring(CLASSPATH.length());
        tp = extractTemplateObject(resPath);
        tp.loader = new ClassPathTemplateLoader(tp.prefix, tp.suffix);
    } else {
        tp = extractTemplateObject(templatePath);
        tp.loader = new FileTemplateLoader(tp.prefix, tp.suffix);
    }

    return tp;
}
 
开发者ID:kongchen,项目名称:swagger-maven-plugin,代码行数:17,代码来源:Utils.java

示例5: TemplateEngine

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
public TemplateEngine(String template) {
    handlebars = new Handlebars(new ClassPathTemplateLoader("/", ""));
    handlebars.registerHelper("json", Jackson2Helper.INSTANCE);
    handlebars.registerHelper("join", StringHelpers.join);
    handlebars.registerHelper("ifequal", IfEqualHelper.INSTANCE);
    handlebars.prettyPrint(true);

    location = "templates/" + template;
}
 
开发者ID:bonitasoft,项目名称:bonita-ui-designer,代码行数:10,代码来源:TemplateEngine.java

示例6: setup

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的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

示例7: HandlebarsTemplateEngine

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
/**
 * Constructs a handlebars template engine
 *
 * @param resourceRoot the resource root
 */
public HandlebarsTemplateEngine(String resourceRoot) {
    TemplateLoader templateLoader = new ClassPathTemplateLoader();
    templateLoader.setPrefix(resourceRoot);
    templateLoader.setSuffix(null);

    handlebars = new Handlebars(templateLoader);

    // Set Guava cache.
    Cache<TemplateSource, Template> cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES)
            .maximumSize(1000).build();

    handlebars = handlebars.with(new GuavaTemplateCache(cache));
}
 
开发者ID:perwendel,项目名称:spark-template-engines,代码行数:19,代码来源:HandlebarsTemplateEngine.java

示例8: initializeTemplateLoader

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
protected static TemplateLoader initializeTemplateLoader(final Configuration loaderConfig) {
    final String type = loaderConfig.getString(TYPE_ATTR);
    final String path = loaderConfig.getString(PATH_ATTR);
    switch (type) {
        case CLASSPATH_TYPE:
            return new ClassPathTemplateLoader(path);
        case FILE_TYPE:
            return new FileTemplateLoader(path);
        default:
            throw new SunriseConfigurationException("Could not initialize Handlebars due to unrecognized template loader \"" + type + "\"", CONFIG_TEMPLATE_LOADERS);
    }
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:13,代码来源:HandlebarsFactory.java

示例9: Hbs

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
/**
 * Creates a new {@link Hbs} module.
 *
 * @param prefix Template prefix.
 * @param suffix Template suffix.
 * @param helpers Optional list of helpers.
 */
public Hbs(final String prefix, final String suffix, final Class<?>... helpers) {
  this.hbs = new Handlebars(new ClassPathTemplateLoader(prefix, suffix));
  with(helpers);
  // default value resolvers.
  this.resolvers.add(MapValueResolver.INSTANCE);
  this.resolvers.add(JavaBeanValueResolver.INSTANCE);
  this.resolvers.add(MethodValueResolver.INSTANCE);
  this.resolvers.add(new RequestValueResolver());
  this.resolvers.add(new SessionValueResolver());
  this.resolvers.add(new ConfigValueResolver());
  this.resolvers.add(FieldValueResolver.INSTANCE);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:20,代码来源:Hbs.java

示例10: withResourceLoaders

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
public Builder withResourceLoaders() {
    log.debug("using resource loaders");
    loaders.add(new ClassPathTemplateLoader());
    loaders.add(new ClassPathTemplateLoader(TemplateLoader.DEFAULT_PREFIX, ".sql"));
    return this;
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:7,代码来源:Templating.java

示例11: initTemplate

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
private static Template initTemplate(String templateName) throws IOException {
  Handlebars handlebars = new Handlebars(new ClassPathTemplateLoader(sf_templatePrefix));
  StringHelpers.register(handlebars);
  handlebars.registerHelpers(ReportHelpers.class);
  return handlebars.compile(templateName);
}
 
开发者ID:PharmGKB,项目名称:PharmCAT,代码行数:7,代码来源:HtmlReportGenerator.java

示例12: templateLoader

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
private static TemplateLoader templateLoader() {
    final List<TemplateLoader> templateLoaders = new ArrayList<>();
    templateLoaders.add(new ClassPathTemplateLoader("/templates")); //overrides
    templateLoaders.add(new ClassPathTemplateLoader("/META-INF/resources/webjars/templates")); //webjar
    return new CompositeTemplateLoader(templateLoaders.toArray(new TemplateLoader[templateLoaders.size()]));
}
 
开发者ID:lauraluiz,项目名称:play-handlebars-demo,代码行数:7,代码来源:HandlebarsService.java

示例13: handlebarsTemplateEngine

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
private static TemplateEngine handlebarsTemplateEngine() {
    final TestableI18nResolver i18nResolver = new TestableI18nResolver(emptyMap());
    final List<TemplateLoader> templateLoaders = singletonList(new ClassPathTemplateLoader("/templates/cmsHelper"));
    final Handlebars handlebars = HandlebarsFactory.create(templateLoaders, i18nResolver, new I18nIdentifierFactory());
    return HandlebarsTemplateEngine.of(handlebars, new HandlebarsContextFactory(new PlayJavaFormResolver(msg -> msg)));
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-java,代码行数:7,代码来源:HandlebarsCmsHelperTest.java

示例14: HandleBarsRepo

import com.github.jknack.handlebars.io.ClassPathTemplateLoader; //导入依赖的package包/类
public HandleBarsRepo() {
	TemplateLoader loader = new ClassPathTemplateLoader();
	loader.setPrefix("/templates");
	loader.setSuffix(".html");
	engine = new Handlebars(loader);
}
 
开发者ID:taichi,项目名称:siden,代码行数:7,代码来源:UseHandlebars.java


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