use of org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer in project cuba by cuba-platform.
the class AppFrontConfig method freemarkerConfig.
@Bean
public FreeMarkerConfigurer freemarkerConfig() {
FreeMarkerConfigurer freemarkerConfig = new FreeMarkerConfigurer();
freemarkerConfig.setTemplateLoaderPath("/front/");
return freemarkerConfig;
}
use of org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer in project wombat by PLOS.
the class WombatControllerTestConfig method freeMarkerConfig.
@Bean
public FreeMarkerConfig freeMarkerConfig(ServletContext servletContext) throws IOException {
String[] templates = getFreeMarkerTemplateDirsForTest();
List<TemplateLoader> loaders = new ArrayList<TemplateLoader>();
for (String template : templates) {
FileTemplateLoader loader = new FileTemplateLoader(new File(servletContext.getRealPath(template)));
loaders.add(loader);
}
MultiTemplateLoader mtl = new MultiTemplateLoader(loaders.toArray(new TemplateLoader[0]));
FreeMarkerConfigurer config = new FreeMarkerConfigurer();
config.setPreTemplateLoaders(mtl);
ImmutableMap.Builder<String, Object> variables = ImmutableMap.builder();
variables.put("formatJsonDate", new Iso8601DateDirective());
variables.put("replaceParams", new ReplaceParametersDirective());
variables.put("siteLink", getEmptyTemplateDirectiveModel());
variables.put("cssLink", getEmptyTemplateDirectiveModel());
variables.put("renderCssLinks", getEmptyTemplateDirectiveModel());
variables.put("js", getEmptyTemplateDirectiveModel());
variables.put("renderJs", getEmptyTemplateDirectiveModel());
variables.put("buildInfo", getEmptyTemplateDirectiveModel());
variables.put("fetchHtml", getEmptyTemplateDirectiveModel());
variables.put("themeConfig", getEmptyTemplateDirectiveModel());
variables.put("appLink", getEmptyTemplateDirectiveModel());
config.setFreemarkerVariables(variables.build());
return config;
}
use of org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer in project tutorials by eugenp.
the class SpringWebConfig method freemarkerConfig.
@Bean
public FreeMarkerConfigurer freemarkerConfig() {
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/ftl/");
return freeMarkerConfigurer;
}
use of org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer in project spring-cloud-netflix by spring-cloud.
the class HystrixDashboardConfiguration method freeMarkerConfigurer.
/**
* Overrides Spring Boot's {@link FreeMarkerAutoConfiguration} to prefer using a
* {@link SpringTemplateLoader} instead of the file system. This corrects an issue
* where Spring Boot may use an empty 'templates' file resource to resolve templates
* instead of the packaged Hystrix classpath templates.
* @return FreeMarker configuration
*/
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
configurer.setTemplateLoaderPaths(DEFAULT_TEMPLATE_LOADER_PATH);
configurer.setDefaultEncoding(DEFAULT_CHARSET);
configurer.setPreferFileSystemAccess(false);
return configurer;
}
use of org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer in project GMM by Katharsas.
the class ApplicationConfiguration method freemarkerConfig.
/**
* FreeMarker (ftl) configuration
*/
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
final FreeMarkerConfigurer result = new FreeMarkerConfigurer();
// template path
result.setTemplateLoaderPath("/WEB-INF/ftl/");
result.setDefaultEncoding("UTF-8");
// static access
final Version version = freemarker.template.Configuration.getVersion();
final BeansWrapper wrapper = new BeansWrapper(version);
final TemplateHashModel statics = wrapper.getStaticModels();
final Map<String, Object> shared = new HashMap<>();
for (final Class<?> clazz : ElFunctions.staticClasses) {
shared.put(clazz.getSimpleName(), statics.get(clazz.getName()));
}
result.setFreemarkerVariables(shared);
return result;
}
Aggregations