本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
};
}
示例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);
};
}
示例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;
}