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


Java JadeConfiguration.setCaching方法代码示例

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


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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: configure

import de.neuland.jade4j.JadeConfiguration; //导入方法依赖的package包/类
@Override
public void configure(final Env env, final Config conf, final Binder binder) {
  JadeConfiguration jadeconf = new JadeConfiguration();
  boolean dev = env.name().equals("dev");
  boolean caching = conf.hasPath("jade.caching")
      ? conf.getBoolean("jade.caching")
      : !dev;
  boolean prettyPrint = conf.hasPath("jade.prettyprint")
      ? conf.getBoolean("jade.prettyprint")
      : dev;

  jadeconf.setCaching(caching);
  jadeconf.setPrettyPrint(prettyPrint);

  Map<String, Object> sharedVariables = new HashMap<>(2);
  sharedVariables.put("env", env);
  sharedVariables.put("xss", new XssHelper(env));
  jadeconf.setSharedVariables(sharedVariables);

  jadeconf.setTemplateLoader(new ClasspathTemplateLoader());

  if (callback != null) {
    callback.accept(jadeconf, conf);
  }

  // rewrite template loader avoid NPE
  jadeconf.setTemplateLoader(new IOTemplateLoader(jadeconf.getTemplateLoader()));

  binder.bind(JadeConfiguration.class)
      .toInstance(jadeconf);

  Multibinder.newSetBinder(binder, Renderer.class).addBinding()
      .toInstance(new Engine(jadeconf, suffix));
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:35,代码来源:Jade.java

示例10: jade

import de.neuland.jade4j.JadeConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Block jade(final String suffix, final boolean caching, final boolean prettyPrint) {
  return unit -> {
    JadeConfiguration jadeConfiguration = unit.mockConstructor(JadeConfiguration.class);
    jadeConfiguration.setCaching(caching);
    jadeConfiguration.setPrettyPrint(prettyPrint);

    Env env = unit.get(Env.class);
    Map<String, Object> sharedVariables = unit.constructor(HashMap.class)
        .build(2);
    expect(sharedVariables.put(eq( "env"), eq(env))).andReturn(null);
    expect(sharedVariables.put(eq( "xss"), isA(XssHelper.class))).andReturn(null);
    jadeConfiguration.setSharedVariables(sharedVariables);

    ClasspathTemplateLoader classpathTemplateLoader = unit
        .mockConstructor(ClasspathTemplateLoader.class);
    jadeConfiguration.setTemplateLoader(classpathTemplateLoader);
    expect(jadeConfiguration.getTemplateLoader()).andReturn(classpathTemplateLoader);

    Jade.IOTemplateLoader safetl = unit
        .constructor(Jade.IOTemplateLoader.class)
        .build(classpathTemplateLoader);
    jadeConfiguration.setTemplateLoader(safetl);

    AnnotatedBindingBuilder<JadeConfiguration> configBB = unit
        .mock(AnnotatedBindingBuilder.class);
    configBB.toInstance(jadeConfiguration);

    Binder binder = unit.get(Binder.class);
    expect(binder.bind(JadeConfiguration.class)).andReturn(configBB);

    Engine engine = unit.mockConstructor(
        Engine.class, new Class[]{JadeConfiguration.class, String.class },
        jadeConfiguration, suffix);

    LinkedBindingBuilder<Renderer> ffLBB = unit.mock(LinkedBindingBuilder.class);
    ffLBB.toInstance(engine);

    Multibinder<Renderer> formatter = unit.mock(Multibinder.class);
    expect(formatter.addBinding()).andReturn(ffLBB);

    unit.mockStatic(Multibinder.class);
    expect(Multibinder.newSetBinder(binder, Renderer.class)).andReturn(formatter);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:46,代码来源:JadeTest.java


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