Spring Framework FreeMarkerConfigurer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework FreeMarkerConfigurer class.

This code example shows how to use the following methods:setFreemarkerSettings, setTemplateLoaderPath
    { 
        final Properties settings = new Properties(); 
        settings.setProperty( "number_format", "0.######" ); 
        settings.setProperty( "default_encoding", "UTF-8" ); 
 
        final FreeMarkerConfigurer bean = new FreeMarkerConfigurer(); 
        bean.setTemplateLoaderPath( "/WEB-INF/freemarker/" ); 
        bean.setFreemarkerSettings( settings ); 
        return bean; 
    } 
 
    @Bean 
    public FreeMarkerViewResolver freeMarkerViewResolver() 
    { 
        final FreeMarkerViewResolver bean = new FreeMarkerViewResolver(); 
        bean.setCache( true ); 
        bean.setPrefix( "" ); 
        bean.setSuffix( ".ftl" ); 
        bean.setExposeSpringMacroHelpers( true ); 
        return bean; 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setFreemarkerVariables, setTemplateLoaderPath
        return resolver; 
    } 
 
    @Bean 
    public FreeMarkerConfigurer freemarkerConfig() { 
        FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); 
        freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/freemarker/"); 
        HashMap<String, Object> freemarkerVariables = freemarkerVariables(); 
        freeMarkerConfigurer.setFreemarkerVariables(freemarkerVariables); 
        return freeMarkerConfigurer; 
    } 
 
    private HashMap<String, Object> freemarkerVariables() { 
        HashMap<String, Object> freemarkerVariables = new HashMap<String, Object>(); 
        freemarkerVariables.put("xml_escape", new XmlEscape()); 
        return freemarkerVariables; 
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
package example.ftl; 
 
import freemarker.cache.TemplateLoader; 
import freemarker.template.Configuration; 
import freemarker.template.TemplateException; 
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; 
 
import java.io.IOException; 
import java.util.List; 
 
public class HtmlFreeMarkerConfigurer extends FreeMarkerConfigurer { 
 
    @Override 
    protected TemplateLoader getAggregateTemplateLoader(List<TemplateLoader> templateLoaders) { 
        logger.info("Using HtmlTemplateLoader to enforce HTML-safe content"); 
        return new HtmlTemplateLoader(super.getAggregateTemplateLoader(templateLoaders)); 
    } 
 
    @Override 
    protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) { 

4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setPostTemplateLoaders
	@Override 
	public FreeMarkerConfigurer freeMarkerConfigurer() throws IOException, TemplateException 
	{ 
		FreeMarkerConfigurer result = super.freeMarkerConfigurer(); 
		// Look up unknown templates in the FreemarkerTemplate repository 
		result.setPostTemplateLoaders(new RepositoryTemplateLoader(freemarkerTemplateRepository)); 
		return result; 
	} 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    /** 
     * Configure for all the template loaders to use escaping wrapper 
     * @author agrebneva 
     * 
     */ 
    public static class HtmlEscapingFreeMarkerConfigurer extends FreeMarkerConfigurer { 
        @Override 
        protected TemplateLoader getAggregateTemplateLoader(List<TemplateLoader> templateLoaders) { 
            return new HtmlEscapingFreeMarkerTemplateLoader(super.getAggregateTemplateLoader(templateLoaders)); 
        } 
    } 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; 
 
import freemarker.cache.FileTemplateLoader; 
import freemarker.cache.TemplateLoader; 
 
public class HippyFreeMarkerConfigurer extends FreeMarkerConfigurer { 
	 
	@Override 
	protected TemplateLoader getTemplateLoaderForPath(String templateLoaderPath) { 
		if (isPreferFileSystemAccess() || templateLoaderPath.startsWith("/WEB-INF")) { 
			// Try to load via the file system, fall back to SpringTemplateLoader 
			// (for hot detection of template changes, if possible). 
			try { 
				Resource path = getResourceLoader().getResource(templateLoaderPath); 
				File file = path.getFile();  // will fail if not resolvable in the file system 
				if (logger.isDebugEnabled()) { 
					logger.debug( 
							"Template loader path [" + path + "] resolved to file path [" + file.getAbsolutePath() + "]"); 
				} 
				return new FileTemplateLoader(file); 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getConfiguration
				"tplMessageSource configuration cannot be null!"); 
	} 
 
	public void setFreeMarkerConfigurer( 
			FreeMarkerConfigurer freeMarkerConfigurer) { 
		this.conf = freeMarkerConfigurer.getConfiguration(); 
	} 
 
	public void setTplMessageSource(MessageSource tplMessageSource) { 
		this.tplMessageSource = tplMessageSource; 
	} 
 
	@Autowired 
	public void setStaticPageDao(StaticPageDao staticPageDao) { 
		this.staticPageDao = staticPageDao; 
	} 
 
	@Autowired 
	public void setRealPathResolver(RealPathResolver realPathResolver) { 
		this.realPathResolver = realPathResolver; 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getConfiguration
	public void runPythonScript(String scriptName, String templateName, Map<String, Object> parameters, 
			PythonOutputHandler outputHandler) throws IOException, TemplateException 
	{ 
		File pythonScriptFile = fileStore.getFile(scriptName); 
 
		Template template = freeMarkerConfig.getConfiguration().getTemplate(templateName); 
		Writer w = new FileWriterWithEncoding(pythonScriptFile, CHARSET); 
 
		try 
		{ 
			template.process(parameters, w); 
		} 
		finally 
		{ 
			IOUtils.closeQuietly(w); 
		} 
 
		pythonScriptExecutor.executeScript(pythonScriptFile, outputHandler); 
	} 
 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getConfiguration
	public void runRScript(String scriptName, String templateName, Map<String, Object> parameters, 
			ROutputHandler outputHandler) throws IOException, TemplateException 
	{ 
		File rScriptFile = fileStore.getFile(scriptName); 
 
		Template template = freeMarkerConfig.getConfiguration().getTemplate(templateName); 
		Writer w = new FileWriterWithEncoding(rScriptFile, CHARSET); 
 
		try 
		{ 
			template.process(parameters, w); 
		} 
		finally 
		{ 
			IOUtils.closeQuietly(w); 
		} 
 
		rScriptExecutor.executeScript(rScriptFile, outputHandler); 
	} 
 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework FreeMarkerConfigurer Methods: