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


Java EngineConfigurationKey类代码示例

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


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

示例1: getEngine

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 * Constructs a template engine with some additional helpers and lambdas for HTML generation.
 */
public MustacheEngine getEngine() {
    if (engine == null) {
        ClassPathTemplateLocator genericLocator = new ClassPathTemplateLocator(PRIO_CLASS_PATH,
            TEMPLATE_PATH, TEMPLATE_SUFFIX);
        MustacheEngineBuilder builder = MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING,
                StandardCharsets.UTF_8.name())
            .addTemplateLocator(genericLocator)
            .registerHelper(ExampleHelper.NAME, new ExampleHelper())
            .registerHelper(TypeLinkHelper.NAME, new TypeLinkHelper())
            .registerHelpers(HelpersBuilder.builtin().addInclude().addInvoke().addSet()
                .addSwitch().addWith().build())
            .addGlobalData(MarkdownLambda.NAME, new MarkdownLambda())
            .addGlobalData(UpperCaseLambda.NAME, new UpperCaseLambda());
        if (templateDir != null) {
            builder.addTemplateLocator(
                new FileSystemTemplateLocator(PRIO_FILE_SYSTEM, templateDir, TEMPLATE_SUFFIX));
        }
        engine = builder.build();
    }
    return engine;
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:26,代码来源:TemplateEngine.java

示例2: getEngine

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 * Constructs a template engine with some additional helpers and lambdas for Typescript
 * generation.
 */
public MustacheEngine getEngine() {
    if (engine == null) {
        ClassPathTemplateLocator genericLocator = new ClassPathTemplateLocator(PRIO_CLASS_PATH,
            TEMPLATE_PATH, TEMPLATE_SUFFIX);
        MustacheEngineBuilder builder = MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING,
                StandardCharsets.UTF_8.name())
            .addTemplateLocator(genericLocator);
        if (templateDir != null) {
            builder.addTemplateLocator(
                new FileSystemTemplateLocator(PRIO_FILE_SYSTEM, templateDir, TEMPLATE_SUFFIX));
        }
        engine = builder.build();
    }
    return engine;
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:21,代码来源:TypescriptTemplateEngine.java

示例3: init

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);
  types = processingEnv.getTypeUtils();
  elements = processingEnv.getElementUtils();
  filer = processingEnv.getFiler();
  messager = processingEnv.getMessager();

  engine = MustacheEngineBuilder
      .newBuilder()
      .addResolver(new MapResolver())
      .addResolver(new ReflectionResolver())
      .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING, StandardCharsets.UTF_8.name())
      .addTemplateLocator(ClassPathTemplateLocator.builder(1)
                              .setClassLoader(this.getClass().getClassLoader())
                              .setSuffix("mustache").build())
      .build();

  messager.printMessage(NOTE, ApiGeneratorProcessor.class.getSimpleName() + " loaded");
}
 
开发者ID:spotify,项目名称:flo,代码行数:21,代码来源:ApiGeneratorProcessor.java

示例4: setup

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@Setup
public void setup() {
    template = MustacheEngineBuilder.newBuilder()
            // Disable HTML escaping
            .setProperty(EngineConfigurationKey.SKIP_VALUE_ESCAPING, true)
            // Disable useless resolver
            .setProperty(CombinedIndexResolver.ENABLED_KEY, false)
            .addTemplateLocator(ClassPathTemplateLocator.builder(1).setRootPath("templates").setScanClasspath(false).setSuffix("trimou.html").build())
            .registerHelpers(HelpersBuilder.extra().build())
            // This is a single purpose helper
            // It's a pity we can't use JDK8 extension and SimpleHelpers util class
            .registerHelper("minusClass", new BasicValueHelper() {
                @Override
                public void execute(Options options) {
                    Object value = options.getParameters().get(0);
                    if (value instanceof Double && (Double) value < 0) {
                        options.append(" class=\"minus\"");
                    }
                    // We don't handle any other number types
                }
            }).build().getMustache("stocks");
    this.context = getContext();
}
 
开发者ID:mbosecke,项目名称:template-benchmark,代码行数:24,代码来源:Trimou.java

示例5: testEncoding

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@Test
public void testEncoding() {

    TemplateLocator locator = new ServletContextTemplateLocator(10,
            "/templates", "html");

    MustacheEngine engine = MustacheEngineBuilder.newBuilder()
            .addTemplateLocator(locator)
            .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING,
                    "windows-1250")
            .build();

    Mustache encoding = engine.getMustache("encoding");
    assertNotNull(encoding);
    assertEquals("Hurá ěščřřžžýá!", encoding.render(null));
}
 
开发者ID:trimou,项目名称:trimou,代码行数:17,代码来源:ServletContextTemplateLocatorTest.java

示例6: produceMustacheEngine

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@ApplicationScoped
@Produces
public MustacheEngine produceMustacheEngine(
        SimpleStatsCollector simpleStatsCollector) {
    // 1. CDI and servlet resolvers are registered automatically
    // 2. Precompile all available templates
    // 3. Do not escape values
    // 4. PrettyTimeHelper is registered automatically
    // 5. Register extra helpers (set, isOdd, ...)
    // 6. ServletContextTemplateLocator is most suitable for webapps
    // 7. The current locale will be based on the Accept-Language header
    // 8. Minify all the templates
    // 9. Collect some basic rendering statistics
    return MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.PRECOMPILE_ALL_TEMPLATES,
                    true)
            .setProperty(EngineConfigurationKey.SKIP_VALUE_ESCAPING, true)
            .registerHelpers(HelpersBuilder.extra()
                    .add("format", new DateTimeFormatHelper()).build())
            .addTemplateLocator(ServletContextTemplateLocator.builder()
                    .setRootPath("/WEB-INF/templates").setSuffix("html")
                    .build())
            .setLocaleSupport(new RequestLocaleSupport())
            .addMustacheListener(Minify.htmlListener())
            .addMustacheListener(simpleStatsCollector).build();
}
 
开发者ID:trimou,项目名称:trimou,代码行数:27,代码来源:MustacheEngineProducer.java

示例7: applyToTrimouMustacheEngineBuilder

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 * Apply the {@link TrimouProperties} to a {@link MustacheEngineBuilder}.
 *
 * @param engineBuilder the Trimou mustache engine builder to apply the properties to
 */
public void applyToTrimouMustacheEngineBuilder(final MustacheEngineBuilder engineBuilder) {
    engineBuilder
            .setProperty(EngineConfigurationKey.START_DELIMITER, getStartDelimiter())
            .setProperty(EngineConfigurationKey.END_DELIMITER, getEndDelimiter())
            .setProperty(EngineConfigurationKey.PRECOMPILE_ALL_TEMPLATES, isPrecompileTemplates())
            .setProperty(EngineConfigurationKey.REMOVE_STANDALONE_LINES, isRemoveStandaloneLines())
            .setProperty(EngineConfigurationKey.REMOVE_UNNECESSARY_SEGMENTS, isRemoveUnnecessarySegments())
            .setProperty(EngineConfigurationKey.DEBUG_MODE, isDebugMode())
            .setProperty(EngineConfigurationKey.CACHE_SECTION_LITERAL_BLOCK, isCacheSectionLiteralBlock())
            .setProperty(EngineConfigurationKey.TEMPLATE_RECURSIVE_INVOCATION_LIMIT,
                    getTemplateRecursiveInvocationLimit())
            .setProperty(EngineConfigurationKey.SKIP_VALUE_ESCAPING, isSkipValueEscaping())
            .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING, getCharset().name())
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_ENABLED, isCache())
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_EXPIRATION_TIMEOUT,
                    getTemplateCacheExpirationTimeout())
            .setProperty(EngineConfigurationKey.HANDLEBARS_SUPPORT_ENABLED, isEnableHelper())
            .setProperty(EngineConfigurationKey.REUSE_LINE_SEPARATOR_SEGMENTS, isReuseLineSeparatorSegments())
            .setProperty(EngineConfigurationKey.ITERATION_METADATA_ALIAS, getIterationMetadataAlias())
            .setProperty(EngineConfigurationKey.RESOLVER_HINTS_ENABLED, isEnableResolverHints())
            .setProperty(EngineConfigurationKey.NESTED_TEMPLATE_SUPPORT_ENABLED, isEnableNestedTemplates())
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_USED_FOR_SOURCE, isCacheTemplateSources());
}
 
开发者ID:trimou,项目名称:trimou,代码行数:29,代码来源:TrimouProperties.java

示例8: cacheDisabled

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@Test
public void cacheDisabled() throws Exception {
    resolver.setEngine(MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_ENABLED, false)
            .setProperty(EngineConfigurationKey.DEBUG_MODE, false)
            .build());
    assertThat(resolver.isCache(), is(false));
    resolver.setEngine(MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_ENABLED, true)
            .setProperty(EngineConfigurationKey.DEBUG_MODE, true)
            .build());
    assertThat(resolver.isCache(), is(false));
    resolver.setEngine(MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_ENABLED, false)
            .setProperty(EngineConfigurationKey.DEBUG_MODE, true)
            .build());
    assertThat(resolver.isCache(), is(false));
    resolver.setEngine(MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_ENABLED, true)
            .setProperty(EngineConfigurationKey.DEBUG_MODE, false)
            .build());
    assertThat(resolver.isCache(), is(true));
    resolver.setCacheLimit(0);
    assertThat(resolver.isCache(), is(false));
}
 
开发者ID:trimou,项目名称:trimou,代码行数:26,代码来源:TrimouViewResolverTest.java

示例9: afterPropertiesSet

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    engine = MustacheEngineBuilder.newBuilder()
            .setProperty(EngineConfigurationKey.TEMPLATE_CACHE_ENABLED,
                    isCache())
            .setProperty(
                    EngineConfigurationKey.TEMPLATE_CACHE_EXPIRATION_TIMEOUT,
                    getCacheExpiration())
            .setProperty(EngineConfigurationKey.DEFAULT_FILE_ENCODING,
                    getFileEncoding())
            .setProperty(EngineConfigurationKey.HANDLEBARS_SUPPORT_ENABLED,
                    isHandlebarsSupport())
            .setProperty(EngineConfigurationKey.DEBUG_MODE, isDebug())
            .setProperty(EngineConfigurationKey.PRECOMPILE_ALL_TEMPLATES,
                    isPreCompile())
            .registerHelpers(helpers)
            .addTemplateLocator(ServletContextTemplateLocator.builder()
                    .setPriority(1).setRootPath(getPrefix())
                    .setSuffix(getSuffixWithoutSeparator())
                    .setServletContext(getServletContext()).build())
            .build();
}
 
开发者ID:trimou,项目名称:trimou,代码行数:23,代码来源:TrimouViewResolver.java

示例10: startTemplate

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
@Override
public void startTemplate(String name, Delimiters delimiters,
        MustacheEngine engine) {

    this.delimiters = delimiters;
    this.engine = engine;
    this.templateName = name;

    containerStack.addFirst(new RootSegmentBase());

    skipValueEscaping = engine.getConfiguration().getBooleanPropertyValue(
            EngineConfigurationKey.SKIP_VALUE_ESCAPING);
    handlebarsSupportEnabled = engine.getConfiguration()
            .getBooleanPropertyValue(
                    EngineConfigurationKey.HANDLEBARS_SUPPORT_ENABLED);

    start = System.currentTimeMillis();
    LOGGER.debug("Start compilation of {}", new Object[] { name });
}
 
开发者ID:trimou,项目名称:trimou,代码行数:20,代码来源:DefaultParsingHandler.java

示例11: identifyTagType

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 * Identify the tag type (variable, comment, etc.).
 *
 * @param buffer
 * @param delimiters
 * @return the tag type
 */
private MustacheTagType identifyTagType(String buffer) {

    if (buffer.length() == 0) {
        return MustacheTagType.VARIABLE;
    }

    // Triple mustache is supported for default delimiters only
    if (delimiters.hasDefaultDelimitersSet()
            && buffer.charAt(0) == ((String) EngineConfigurationKey.START_DELIMITER
                    .getDefaultValue()).charAt(0)
            && buffer.charAt(buffer.length() - 1) == ((String) EngineConfigurationKey.END_DELIMITER
                    .getDefaultValue()).charAt(0)) {
        return MustacheTagType.UNESCAPE_VARIABLE;
    }

    Character command = buffer.charAt(0);

    for (MustacheTagType type : MustacheTagType.values()) {
        if (command.equals(type.getCommand())) {
            return type;
        }
    }
    return MustacheTagType.VARIABLE;
}
 
开发者ID:trimou,项目名称:trimou,代码行数:32,代码来源:DefaultParser.java

示例12: extractContent

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 * Extract the tag content.
 *
 * @param buffer
 * @return
 */
private String extractContent(MustacheTagType tagType, String buffer) {

    switch (tagType) {
    case VARIABLE:
        return buffer.trim();
    case UNESCAPE_VARIABLE:
        return (buffer.charAt(0) == ((String) EngineConfigurationKey.START_DELIMITER
                .getDefaultValue()).charAt(0) ? buffer.substring(1,
                buffer.length() - 1).trim() : buffer.substring(1).trim());
    case SECTION:
    case INVERTED_SECTION:
    case PARTIAL:
    case EXTEND:
    case EXTEND_SECTION:
    case SECTION_END:
    case NESTED_TEMPLATE:
    case COMMENT:
        return buffer.substring(1).trim();
    case DELIMITER:
        return buffer.trim();
    default:
        return null;
    }
}
 
开发者ID:trimou,项目名称:trimou,代码行数:31,代码来源:DefaultParser.java

示例13: buildCache

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
private <K, V> ComputingCache<K, V> buildCache(String name,
        ComputingCache.Function<K, V> loader,
        ComputingCache.Listener<K> listener) {

    Long expirationTimeout = configuration.getLongPropertyValue(
            EngineConfigurationKey.TEMPLATE_CACHE_EXPIRATION_TIMEOUT);

    if (expirationTimeout > 0) {
        LOGGER.info("{} cache expiration timeout set: {} seconds", name, expirationTimeout);
        expirationTimeout = expirationTimeout * 1000L;
    } else {
        expirationTimeout = null;
    }
    return configuration.getComputingCacheFactory().create(
            MustacheEngine.COMPUTING_CACHE_CONSUMER_ID, loader,
            expirationTimeout, null, listener);
}
 
开发者ID:trimou,项目名称:trimou,代码行数:18,代码来源:DefaultMustacheEngine.java

示例14: SectionSegment

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 *
 * @param text
 * @param origin
 * @param segments
 */
public SectionSegment(String text, Origin origin, List<Segment> segments) {
    super(text, origin, segments);
    this.helperHandler = isHandlebarsSupportEnabled()
            ? HelperExecutionHandler.from(text, getEngine(), this) : null;

    if (helperHandler == null) {
        this.iterationMetaAlias = getEngineConfiguration()
                .getStringPropertyValue(
                        EngineConfigurationKey.ITERATION_METADATA_ALIAS);
        this.provider = new ValueProvider(text, getEngineConfiguration());
    } else {
        this.iterationMetaAlias = null;
        this.provider = null;
    }
}
 
开发者ID:trimou,项目名称:trimou,代码行数:22,代码来源:SectionSegment.java

示例15: ValueProvider

import org.trimou.engine.config.EngineConfigurationKey; //导入依赖的package包/类
/**
 *
 * @param text
 * @param configuration
 */
ValueProvider(String text, Configuration configuration) {
    this.key = text;
    ArrayList<String> parts = new ArrayList<>();
    for (Iterator<String> iterator = configuration.getKeySplitter()
            .split(text); iterator.hasNext();) {
        parts.add(iterator.next());
    }
    this.keyParts = parts.toArray(new String[parts.size()]);
    if (configuration.getBooleanPropertyValue(
            EngineConfigurationKey.RESOLVER_HINTS_ENABLED)) {
        this.hint = new AtomicReference<>();
    } else {
        this.hint = null;
    }
}
 
开发者ID:trimou,项目名称:trimou,代码行数:21,代码来源:ValueProvider.java


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