5.9.2. Freemarker settings
MetaFactory supports multiple template engines. Since 2011 Freemarker is supported by MetaFactory. Freemarker is a very powerful template engine to produce source code. Like Velocity, freemarker supports libraries-containing-macros. To make these macro libraries available for other freemarker templates the freemarker element is used:
Usage
1<?xml version="1.0" encoding="UTF-8"?>
2<pattern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns="http://www.firstbase.nl/xsd/personaliom/pattern"
4 xsi:schemaLocation="http://www.firstbase.nl/xsd/personaliom/pattern
5 http://www.firstbase.nl/xsd/personaliom/pattern.xsd">
6
7 ...
8 <freemarker>
9 <freemarkerLibrary namespace="myLib1">relative path to freemarker file with macro's</freemarkerLibrary>
10 <freemarkerLibrary namespace="myLib2">some other path</freemarkerLibrary>
11 </freemarker>
12 ...
13</pattern>
Each freemarkerLibary element loads a freemarker template file. The macro’s defined in this template are made available to the template engine in the specified namespace. If the template file can’t be loaded, MetaFactory returns a error and stops loading the pattern.
Example of a pattern with 2 freemarker libraries defined:
1<?xml version="1.0" encoding="UTF-8"?>
2<pattern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns="http://www.firstbase.nl/xsd/personaliom/pattern"
4 xsi:schemaLocation="http://www.firstbase.nl/xsd/personaliom/pattern
5 http://www.firstbase.nl/xsd/personaliom/pattern.xsd">
6
7 ...
8 <freemarker>
9 <freemarkerLibrary namespace="pf">jsf/primefaces/library/primefacesLayout.ftl</freemarkerLibrary>
10 <freemarkerLibrary namespace="tl">universal/library/layout/tableLayout.ftl</freemarkerLibrary>
11 </freemarker>
12 ...
13</pattern>