當前位置: 首頁>>代碼示例>>Java>>正文


Java Handlebars.with方法代碼示例

本文整理匯總了Java中com.github.jknack.handlebars.Handlebars.with方法的典型用法代碼示例。如果您正苦於以下問題:Java Handlebars.with方法的具體用法?Java Handlebars.with怎麽用?Java Handlebars.with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.jknack.handlebars.Handlebars的用法示例。


在下文中一共展示了Handlebars.with方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MaTemplateEngine

import com.github.jknack.handlebars.Handlebars; //導入方法依賴的package包/類
public MaTemplateEngine(TemplateLoader loader) {
    loader.setSuffix(null);

    handlebars = new Handlebars(loader);

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

    handlebars = handlebars.with(new GuavaTemplateCache(cache));
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLib,代碼行數:12,代碼來源:MaTemplateEngine.java

示例2: HandlebarsTemplateEngine

import com.github.jknack.handlebars.Handlebars; //導入方法依賴的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

示例3: generateBlueprintWithParameters

import com.github.jknack.handlebars.Handlebars; //導入方法依賴的package包/類
private String generateBlueprintWithParameters(String blueprintText, Cluster cluster, Set<RDSConfig> rdsConfigs) throws IOException {
    Handlebars handlebars = new Handlebars();
    handlebars.with(EscapingStrategy.NOOP);
    handlebars.registerHelperMissing(new Helper<Object>() {
        @Override
        public CharSequence apply(final Object context, final Options options) throws IOException {
            return options.fn.text();
        }
    });
    Template template = handlebars.compileInline(blueprintText, "{{{", "}}}");

    return template.apply(prepareTemplateObject(cluster.getBlueprintInputs().get(Map.class), cluster, rdsConfigs));
}
 
開發者ID:hortonworks,項目名稱:cloudbreak,代碼行數:14,代碼來源:BlueprintTemplateProcessor.java

示例4: HandlebarsApi

import com.github.jknack.handlebars.Handlebars; //導入方法依賴的package包/類
/**
 * Initialize Handlebars engine, register cache, handlers.
 * 
 * @param environment
 *            Play environment, used for getting templates folder. 
 *            Could be null for the inline rendering.
 * @param config
 *            Play configuration, used for getting properties.
 * @param messagesApi
 *            MessagesApi, used in message helper.
 * @param assetsFinder
 *            AssetsFinder, used in assets helper.
 */
@Inject
public HandlebarsApi(
		final Environment environment, 
		final Config config,
		final MessagesApi messagesApi,
		final AssetsFinder assetsFinder) {

	this.messagesApi = messagesApi;
	this.assetsFinder = assetsFinder;
	
	// Initialize the properties.
	final Properties properties = new Properties(config);

	// Get the template folder.
	final File rootFolder = 
			(environment == null) ? null : environment.getFile(properties.getDirectory());

	// Put the template extension.
	final TemplateLoader loader = 
			(rootFolder == null) ? null : new FileTemplateLoader(rootFolder, properties.getExtension());

	// Initialize the engine with the cache
	handlebars = new Handlebars(loader);

	if (properties.isCacheEnabled()) {
		// Initialize the cache. Could be builded from configuration as well
		// For example:
		// CacheBuilder.from(config.getString("hbs.cache")).build()
		final Cache<TemplateSource, Template> cache = CacheBuilder.newBuilder()
				.expireAfterWrite(10, TimeUnit.MINUTES).maximumSize(1000).build();
		final GuavaTemplateCache guavaCache = new GuavaTemplateCache(cache);
		handlebars.with(guavaCache);
	}

	// Add helpers. 
	// MessagesApi is a singleton so we can use it in helpers.
	// All assets helpers will use this AssetsFinder.
	PlayHelpers helpers = new PlayHelpers(messagesApi, assetsFinder, environment);
	handlebars.registerHelpers(helpers);
	handlebars.registerHelpers(StringHelpers.class);
}
 
開發者ID:andriykuba,項目名稱:play-handlebars,代碼行數:55,代碼來源:HandlebarsApi.java


注:本文中的com.github.jknack.handlebars.Handlebars.with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。