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


Java PebbleEngine.Builder方法代码示例

本文整理汇总了Java中com.mitchellbosecke.pebble.PebbleEngine.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleEngine.Builder方法的具体用法?Java PebbleEngine.Builder怎么用?Java PebbleEngine.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mitchellbosecke.pebble.PebbleEngine的用法示例。


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

示例1: pebbleEngine

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
@Bean
public PebbleEngine pebbleEngine() {
    PebbleEngine.Builder builder = new PebbleEngine.Builder();
    builder.loader(this.pebbleLoader);
    builder.extension(this.pebbleSpringExtension());
    if (this.extensions != null && !this.extensions.isEmpty()) {
        builder.extension(this.extensions.toArray(new Extension[this.extensions.size()]));
    }
    if (!this.properties.isCache()) {
        builder.cacheActive(false);
    }
    if (this.properties.getDefaultLocale() != null) {
        builder.defaultLocale(this.properties.getDefaultLocale());
    }
    builder.strictVariables(this.properties.isStrictVariables());
    return builder.build();
}
 
开发者ID:PebbleTemplates,项目名称:pebble-spring-boot-starter,代码行数:18,代码来源:PebbleAutoConfiguration.java

示例2: createPebbleEngine

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
/**
 * Creates a PebbleEngine instance.
 *
 * @return a PebbleEngine object that can be used to create PebbleTemplate objects
 */
public PebbleEngine createPebbleEngine() {
    PebbleEngine.Builder builder = new PebbleEngine.Builder();
    builder.strictVariables(strictVariables);

    if (defaultLocale != null) {
        builder.defaultLocale(defaultLocale);
    }

    if (templateLoaders == null) {
        if (templateLoaderPaths != null && templateLoaderPaths.length > 0) {
            List<Loader<?>> templateLoaderList = new ArrayList<>();
            for (String path : templateLoaderPaths) {
                templateLoaderList.add(getTemplateLoaderForPath(path));
            }
            setTemplateLoader(templateLoaderList);
        }
    }

    Loader<?> templateLoader = getAggregateTemplateLoader(templateLoaders);
    builder.loader(templateLoader);

    return builder.build();
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:29,代码来源:PebbleEngineFactory.java

示例3: getPebbleEngine

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
public PebbleEngine getPebbleEngine() {

        final PebbleEngine.Builder builder = new PebbleEngine.Builder()
                .loader(this.loader)
                .extension(extensions.toArray(new Extension[extensions.size()]));

        if (cache) {
            builder.templateCache(CacheBuilder.newBuilder().maximumSize(cacheSize).build())
                    .tagCache(CacheBuilder.newBuilder().maximumSize(cacheSize).build());
        } else {
            builder.templateCache(CacheBuilder.newBuilder().maximumSize(0).build())
                    .tagCache(CacheBuilder.newBuilder().maximumSize(0).build());
        }

        log.debug("PebbleEngine built! 这里不写几个汉字不显眼!!!");
        return builder.build();
    }
 
开发者ID:LionelWoody,项目名称:spring-boot-starter-pebble,代码行数:18,代码来源:PebbleEngineConfigurer.java

示例4: init

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
@Override
public void init(Application application) {
    super.init(application);

    Router router = getRouter();
    PippoSettings pippoSettings = getPippoSettings();

    List<Loader<?>> loaders = Lists.newArrayList();
    PippoTemplateLoader templateLoader = new PippoTemplateLoader();

    templateLoader.setCharset(PippoConstants.UTF8);
    templateLoader.setPrefix(getTemplatePathPrefix());
    templateLoader.setSuffix("." + getFileExtension());
    loaders.add(templateLoader);

    PebbleEngine.Builder builder = new PebbleEngine.Builder()
        .loader(new DelegatingLoader(loaders))
        .strictVariables(false)
        .extension(new GlobalVariablesExtension()
            .set("contextPath", router.getContextPath())
            .set("appPath", router.getApplicationPath()))
        .extension(new I18nExtension(application.getMessages()))
        .extension(new FormatTimeExtension())
        .extension(new PrettyTimeExtension())
        .extension(new AngularJSExtension())
        .extension(new WebjarsAtExtension(router))
        .extension(new PublicAtExtension(router));

    if (pippoSettings.isDev()) {
        // do not cache templates in dev mode
        builder.cacheActive(false);
        builder.extension(new DebugExtension());
    }

    // allow custom initialization
    init(application, builder);

    engine = builder.build();
}
 
开发者ID:decebals,项目名称:pippo,代码行数:40,代码来源:PebbleTemplateEngine.java

示例5: cacheBuilder

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
private Block cacheBuilder(final int maxSize) {
  return unit -> {
    Cache<Object, PebbleTemplate> cache = unit.mock(Cache.class);
    unit.registerMock(Cache.class, cache);

    CacheBuilder cachebuilder = unit.mock(CacheBuilder.class);
    expect(CacheBuilder.from("maximumSize=" + maxSize)).andReturn(cachebuilder);
    expect(cachebuilder.build()).andReturn(cache);

    PebbleEngine.Builder pebble = unit.get(PebbleEngine.Builder.class);
    expect(pebble.templateCache(cache)).andReturn(pebble);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:PebbleTest.java

示例6: tagCache

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
private Block tagCache(final int size) {
  return unit -> {
    Cache<BaseTagCacheKey, Object> cache = unit.mock(Cache.class);

    CacheBuilder cachebuilder = unit.mock(CacheBuilder.class);
    expect(CacheBuilder.newBuilder()).andReturn(cachebuilder);
    expect(cachebuilder.maximumSize(size)).andReturn(cachebuilder);
    expect(cachebuilder.build()).andReturn(cache);

    PebbleEngine.Builder pebble = unit.get(PebbleEngine.Builder.class);
    expect(pebble.tagCache(cache)).andReturn(pebble);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:PebbleTest.java

示例7: doWith

import com.mitchellbosecke.pebble.PebbleEngine; //导入方法依赖的package包/类
/**
 * Advanced configuration callback for {@link PebbleEngine.Builder}.
 *
 * @param callback A callback to finish setup.
 * @return This module.
 */
public Pebble doWith(final BiConsumer<PebbleEngine.Builder, Config> callback) {
  this.callback = requireNonNull(callback, "Callback is required.");
  return this;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:11,代码来源:Pebble.java


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