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


Java JadeConfiguration类代码示例

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


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

示例1: produce

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Produces
@ViewEngineConfig
JadeConfiguration produce() {
    loadConfig();
    JadeConfiguration jade = new JadeConfiguration();
    jade.setMode(Mode.valueOf(property(MODE).orElse("XHTML")));
    jade.setCaching(Boolean.valueOf(property(CACHING).orElse("true")));
    jade.setPrettyPrint(Boolean.valueOf(property(PRETTY_PRINT).orElse("false")));
    for (Map.Entry<String, Object> filter : getExtensions(FILTER_QUALIFIER).entrySet()) {
        jade.setFilter(filter.getKey(), (Filter) filter.getValue());
    }
    jade.setSharedVariables(getExtensions(HELPER_QUALIFIER));
    String encoding = property(ENCODING).orElse("UTF-8");
    jade.setTemplateLoader(new ServletContextTemplateLoader(servletContext, encoding));
    return jade;
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:17,代码来源:JadeOzarkConfiguration.java

示例2: init

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Override
public void init(Application application) {
    super.init(application);

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

    configuration = new JadeConfiguration();
    configuration.setTemplateLoader(new ClassTemplateLoader(JadeTemplateEngine.class, getTemplatePathPrefix()));
    configuration.setMode(Mode.HTML);
    if (pippoSettings.isDev()) {
        configuration.setPrettyPrint(true);
        configuration.setCaching(false); // disable cache
    }

    // set global template variables
    configuration.getSharedVariables().put("contextPath", router.getContextPath());
    configuration.getSharedVariables().put("appPath", router.getApplicationPath());

    // allow custom initialization
    init(application, configuration);
}
 
开发者ID:decebals,项目名称:pippo,代码行数:23,代码来源:JadeTemplateEngine.java

示例3: shouldRenderPrettyTemplateTemplate

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Test
public void shouldRenderPrettyTemplateTemplate() throws Exception {
  EnvironmentTestUtils.addEnvironment(this.context, "spring.jade4j.prettyPrint:true");
  this.context.register(Jade4JAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
  this.context.refresh();
  JadeConfiguration engine = this.context.getBean(JadeConfiguration.class);
  JadeTemplate template = engine.getTemplate("demo.jade");
  Map<String, Object> params = Collections.emptyMap();
  String result = engine.renderTemplate(template, params);
  String expected = "<html>\n" +
      "  <head>\n" +
      "    <title>Jade</title>\n" +
      "  </head>\n" +
      "  <body>\n" +
      "    <h1>Jade - Template engine</h1>\n" +
      "  </body>\n" +
      "</html>";
  assertEquals(expected, result.trim());
}
 
开发者ID:domix,项目名称:spring-boot-starter-jade4j,代码行数:20,代码来源:Jade4JAutoConfigurationTests.java

示例4: renderNonWebAppTemplate

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Test
@Ignore
public void renderNonWebAppTemplate() throws Exception {
  AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
      Jade4JAutoConfiguration.class,
      PropertyPlaceholderAutoConfiguration.class);
  assertEquals(0, context.getBeanNamesForType(ViewResolver.class).length);
  try {
    JadeConfiguration engine = this.context.getBean(JadeConfiguration.class);
    JadeTemplate template = engine.getTemplate("demo.jade");
    Map<String, Object> params = params();
    String result = engine.renderTemplate(template, params);

    assertThat(result, containsString("With user"));
  } finally {
    context.close();
  }
}
 
开发者ID:domix,项目名称:spring-boot-starter-jade4j,代码行数:19,代码来源:Jade4JAutoConfigurationTests.java

示例5: configureJade4J

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
private void configureJade4J() {
    jadeConfiguration = new JadeConfiguration();
    String srcDir = buildSrcDir();

    if ((ninjaProperties.isDev() || ninjaProperties.isTest())
            && new File(srcDir).exists()) {
        jadeConfiguration.setTemplateLoader(new FileTemplateLoader(srcDir,
                "UTF-8"));
        jadeConfiguration.setCaching(false);
        jadeConfiguration.setPrettyPrint(true);
    } else {
        jadeConfiguration.setTemplateLoader(new ClasspathTemplateLoader());
        jadeConfiguration.setCaching(true);
        jadeConfiguration.setPrettyPrint(false);
    }

    jadeConfiguration.setMode(Mode.HTML);

}
 
开发者ID:mysu,项目名称:jade4ninja,代码行数:20,代码来源:TemplateEngineJade4J.java

示例6: JadeViewRenderer

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
/**
 * JadeViewRenderer constructor that allows you to provide an instance
 * of the object mapper.
 * @param objectMapper
 */
private JadeViewRenderer(ObjectMapper objectMapper) {
    this.mapper = objectMapper;
    this.cache = CacheBuilder.newBuilder()
        .build(new CacheLoader<Class<? extends View>, JadeConfiguration>() {
            @Override
            public JadeConfiguration load(Class<? extends View> aClass) throws Exception {
                logger.debug("building new JadeConfiguration for views class {}", aClass);
                JadeConfiguration config = new JadeConfiguration();
                config.setTemplateLoader(new JadeTemplateLoader(aClass));
                return config;
            }
        });
}
 
开发者ID:gethalfpintoss,项目名称:dropwizard-views-jade,代码行数:19,代码来源:JadeViewRenderer.java

示例7: jadeConfiguration

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(JadeConfiguration.class)
public JadeConfiguration jadeConfiguration(TemplateLoader jadeTemplateLoader) {
	JadeConfiguration configuration = new JadeConfiguration();
	configuration.setCaching(false); //Cache is handled by spring
	configuration.setPrettyPrint(properties.isPrettyPrint());
	configuration.setTemplateLoader(jadeTemplateLoader);
	//configuration.setSharedVariables(sharedVariables);
	//configuration.setFilter(name, filter);
	//configuration.setMode(mode);
	return configuration;
}
 
开发者ID:marlonbernardes,项目名称:spring-boot-jade,代码行数:13,代码来源:JadeAutoConfiguration.java

示例8: jadeViewResolver

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(JadeViewResolver.class)
public JadeViewResolver jadeViewResolver(JadeConfiguration jadeConfiguration) {
	JadeViewResolver resolver = new JadeViewResolver();
	resolver.setPrefix(properties.getPrefix());
	resolver.setSuffix(properties.getSuffix());
	resolver.setCache(properties.isCache());
	resolver.setViewNames(properties.getViewNames());
	resolver.setContentType(properties.getContentType());
	resolver.setJadeConfiguration(jadeConfiguration);
	resolver.setOrder(Ordered.LOWEST_PRECEDENCE-10);
	return resolver;
}
 
开发者ID:marlonbernardes,项目名称:spring-boot-jade,代码行数:14,代码来源:JadeAutoConfiguration.java

示例9: jadeConfiguration

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Bean
public JadeConfiguration jadeConfiguration(TemplateLoader jadeTemplateLoader) {
	JadeConfiguration configuration = new JadeConfiguration();
	configuration.setCaching(false); 
	configuration.setPrettyPrint(true);
	configuration.setTemplateLoader(jadeTemplateLoader);
	return configuration;
}
 
开发者ID:marlonbernardes,项目名称:spring-boot-jade,代码行数:9,代码来源:ApplicationTests.java

示例10: jadeViewResolver

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Bean
public JadeViewResolver jadeViewResolver(JadeConfiguration jadeConfiguration) {
	JadeViewResolver resolver = new JadeViewResolver();
	resolver.setPrefix("classpath:/templates/");
	resolver.setSuffix(".jade");
	resolver.setCache(false);
	resolver.setJadeConfiguration(jadeConfiguration);
	resolver.setOrder(Ordered.LOWEST_PRECEDENCE-10);
	return resolver;
}
 
开发者ID:marlonbernardes,项目名称:spring-boot-jade,代码行数:11,代码来源:ApplicationTests.java

示例11: renderString

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Override
public void renderString(String templateContent, Map<String, Object> model, Writer writer) {
    // prepare the locale-aware i18n method
    String language = (String) model.get(PippoConstants.REQUEST_PARAMETER_LANG);
    if (StringUtils.isNullOrEmpty(language)) {
        language = getLanguageOrDefault(language);
    }

    // prepare the locale-aware prettyTime method
    Locale locale = (Locale) model.get(PippoConstants.REQUEST_PARAMETER_LOCALE);
    if (locale == null) {
        locale = getLocaleOrDefault(language);
    }

    model.put("pippo", new PippoHelper(getMessages(), language, locale, getRouter()));
    try (StringReader reader = new StringReader(templateContent)) {
        ReaderTemplateLoader stringTemplateLoader = new ReaderTemplateLoader(reader, "StringTemplate");

        JadeConfiguration stringTemplateConfiguration = new JadeConfiguration();
        stringTemplateConfiguration.setCaching(false);
        stringTemplateConfiguration.setTemplateLoader(stringTemplateLoader);
        stringTemplateConfiguration.setMode(configuration.getMode());
        stringTemplateConfiguration.setPrettyPrint(configuration.isPrettyPrint());

        JadeTemplate stringTemplate = configuration.getTemplate("StringTemplate");
        configuration.renderTemplate(stringTemplate, model, writer);
        writer.flush();
    } catch (Exception e) {
        throw new PippoRuntimeException(e);
    }
}
 
开发者ID:decebals,项目名称:pippo,代码行数:32,代码来源:JadeTemplateEngine.java

示例12: getJadeTemplate

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
private JadeTemplate getJadeTemplate(String templatePath) throws IOException {
  JadeConfiguration config = new JadeConfiguration();
  if (isDebugEnabled) {
    config.clearCache();
    config.setCaching(false);
  }
  config.setTemplateLoader(new ClasspathTemplateLoader());
  return config.getTemplate(templatePath);
}
 
开发者ID:orctom,项目名称:laputa,代码行数:10,代码来源:JadeContentTranslator.java

示例13: defaultJadeConfiguration

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Bean
public JadeConfiguration defaultJadeConfiguration() {
  JadeConfiguration configuration = new JadeConfiguration();
  configuration.setCaching(this.environment.getProperty("caching", Boolean.class, true));
  configuration.setTemplateLoader(defaultSpringTemplateLoader());
  configuration.setPrettyPrint(this.environment.getProperty("prettyPrint", Boolean.class, false));
  configuration.setMode(this.environment.getProperty("mode", Jade4J.Mode.class, Jade4J.Mode.HTML));
  return configuration;
}
 
开发者ID:domix,项目名称:spring-boot-starter-jade4j,代码行数:10,代码来源:Jade4JAutoConfiguration.java

示例14: shouldRenderTemplateAsExpected

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Test
public void shouldRenderTemplateAsExpected() throws Exception {
  EnvironmentTestUtils.addEnvironment(this.context, "spring.jade4j.mode:XHTML");
  this.context.register(Jade4JAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
  this.context.refresh();
  JadeConfiguration engine = this.context.getBean(JadeConfiguration.class);
  JadeTemplate template = engine.getTemplate("demo.jade");
  Map<String, Object> params = Collections.emptyMap();
  String result = engine.renderTemplate(template, params);
  String expected = "<html><head><title>Jade</title></head><body><h1>Jade - Template engine</h1></body></html>";

  assertEquals(expected, result);
}
 
开发者ID:domix,项目名称:spring-boot-starter-jade4j,代码行数:14,代码来源:Jade4JAutoConfigurationTests.java

示例15: shouldRenderTemplateWithParams

import de.neuland.jade4j.JadeConfiguration; //导入依赖的package包/类
@Test
public void shouldRenderTemplateWithParams() throws Exception {
  EnvironmentTestUtils.addEnvironment(this.context, "spring.jade4j.mode:XHTML");
  this.context.register(Jade4JAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
  this.context.refresh();
  JadeConfiguration engine = this.context.getBean(JadeConfiguration.class);
  JadeTemplate template = engine.getTemplate("demo.jade");
  Map<String, Object> params = params();
  String result = engine.renderTemplate(template, params);
  String expected = "<html><head><title>Jade</title></head><body><h1>Jade - Template engine</h1><h2>With user</h2></body></html>";
  assertEquals(expected, result);
}
 
开发者ID:domix,项目名称:spring-boot-starter-jade4j,代码行数:13,代码来源:Jade4JAutoConfigurationTests.java


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