Allow for wiring global macro Freemarker library's within FreemarkerManager
---------------------------------------------------------------------------
Key: WW-3079
URL: https://issues.apache.org/struts/browse/WW-3079
Project: Struts 2
Issue Type: Improvement
Components: Integration
Affects Versions: 2.1.8
Reporter: Matthew Payne
Something similar can can be setup via for velocity Macro's . We should be
able to set certain macro libs as global without needing to import them
directly in our freemarker templates.
Such a setting is currently not available in the current FreemarkerManager
example of setting this up in another project(not struts based).
reference -->
http://svn.riotfamily.org/svn/riotfamily/trunk/website/META-INF/riot/website-servlet.xml
---> notice macro lib property
<bean id="freemarkerConfig"
class="org.riotfamily.website.freemarker.WebsiteFreeMarkerConfigurer">
<description>
FreeMarker configuration.
</description>
<property name="defaultEncoding" value="UTF-8" />
<property name="templateLoaderPaths">
<list>
<value>/WEB-INF/view</value>
</list>
</property>
<property name="freemarkerSettings"
value="${website-servlet.freemarker.*}" />
<property name="useTemplateCache"
value="${website-servlet.useTemplateCache=true}" />
<property name="macroLibraries">
<props>
<prop
key="c">classpath:org/riotfamily/website/view/common.ftl</prop>
<prop
key="form">classpath:org/riotfamily/website/form/form.ftl</prop>
<prop
key="template">classpath:org/riotfamily/website/template/template.ftl</prop>
<prop
key="txt2img">classpath:org/riotfamily/website/txt2img/txt2img.ftl</prop>
</props>
</property>
<property name="whitespaceStripping" value="true" />
</bean>
http://www.java2s.com/Open-Source/Java-Document/Content-Management-System/riotfamily/org/riotfamily/common/web/view/freemarker/RiotFreeMarkerConfigurer.java.htm
protected void importMacroLibraries(Configuration config) {
192: if (macroLibraries != null) {
193: Enumeration names = macroLibraries.propertyNames();
194: while (names.hasMoreElements()) {
195: String namespace = (String) names.nextElement();
196: String lib = macroLibraries.getProperty(namespace);
197: log
198: .info(lib + " imported under namespace "
199: + namespace);
200: config.addAutoImport(namespace, lib);
201: }
202: }
203: }
/**
074: * Sets the macro libraries to be auto-imported, keyed by their
namespace.
075: */
076: public void setMacroLibraries(Properties macroLibraries) {
077: this .macroLibraries = macroLibraries;
078: }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.