This plugin provides an add-on
allowing Route Handlers
to easily access templating functionalities.
Make sure you read the section dedicated to the Templating Engine for more information.
If you use the spincast-default
artifact and the standard Bootstrapper,
this plugin is already installed by default so you have nothing to do!
If you start from scratch, using the spincast-core
artifact, you can use the
plugin by :
1. Adding this Maven artifact to your project:
<dependency> <groupId>org.spincast</groupId> <artifactId>spincast-plugins-templating-addon</artifactId> <version>2.2.0</version> </dependency>
2. Installing the provided SpincastTemplatingAddonPluginModule module to your Guice context.
The class implementing the SpincastPlugin interface is SpincastTemplatingAddonPlugin.
templating()
Route Handlers
easy access to templating functionalities.
Example :
public void myHandler(AppRequestContext context) { Map<String, Object> params = new HashMap<String, Object>(); params.set("name", "Stromgol"); String html = context.templating().evaluate("<h1>Hi {{name}}!</h1>", params); System.out.println(html); // <h1>Hi Stromgol!</h1> }
This add-on is already installed by default on the Request Context type.