| <?xml version="1.0"?> |
| |
| <document> |
| <properties> |
| <title>Turbine Services - FreeMarker Service</title> |
| <author email="jvanzyl@apache.org">Jason van Zyl</author> |
| <author email="jon@latchkey.com">Jon S. Stevens</author> |
| </properties> |
| |
| <body> |
| |
| <section name="FreeMarker Service"> |
| |
| <p> |
| Turbine has support for using <a |
| href="http://freemarker.sourceforge.net/">FreeMarker</a> as a templating |
| tool. This is made available through our services architecture. While |
| Turbine supports the use of many templating systems, we definitely have |
| our favorite system to use and recommend and that is <a |
| href="http://jakarta.apache.org/velocity/">Velocity</a>. |
| </p> |
| |
| </section> |
| |
| <section name="Configuration"> |
| |
| <source><![CDATA[ |
| |
| # ------------------------------------------------------------------- |
| # |
| # S E R V I C E S |
| # |
| # ------------------------------------------------------------------- |
| # Classes for Turbine Services should be defined here. |
| # Format: services.[name].classname=[implementing class] |
| # |
| # To specify properties of a service use the following syntax: |
| # service.[name].[property]=[value] |
| |
| services.FreeMarkerService.classname=org.apache.turbine.services.freemarker.TurbineFreeMarkerService |
| . |
| . |
| . |
| ]]></source> |
| |
| </section> |
| |
| <section name="Usage"> |
| |
| <source><![CDATA[ |
| FreeMarkerService fm = (FreeMarkerService)TurbineServices.getInstance() |
| .getService(FreeMarkerService.SERVICE_NAME); |
| SimpleHash context = fm.getContext(data); |
| context.put("message", "Hello from Turbine!"); |
| String results = fm.handleRequest(context,"helloWorld.wm"); |
| data.getPage().getBody().addElement(results); |
| ]]></source> |
| |
| </section> |
| |
| </body> |
| </document> |