本文整理汇总了Java中de.neuland.jade4j.JadeConfiguration.setTemplateLoader方法的典型用法代码示例。如果您正苦于以下问题:Java JadeConfiguration.setTemplateLoader方法的具体用法?Java JadeConfiguration.setTemplateLoader怎么用?Java JadeConfiguration.setTemplateLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.neuland.jade4j.JadeConfiguration
的用法示例。
在下文中一共展示了JadeConfiguration.setTemplateLoader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
示例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);
};
}
示例11: JadeTemplateEngine
import de.neuland.jade4j.JadeConfiguration; //导入方法依赖的package包/类
/**
* Construct a jade template engine with specified root.
*
* @param templateRoot the template root directory to use
*/
public JadeTemplateEngine(String templateRoot) {
configuration = new JadeConfiguration();
configuration.setTemplateLoader(new SparkClasspathTemplateLoader(templateRoot));
}