Render Extension
The render extension, only available for web apps, enables users to embed the result of rendering a given path. It can be seen as another way to include other resources available throught HTTP GET endpoints. This extension exposes a new tag render
.
render
tag
The render tag is expecting a path to an internal resource and, optionally, a map of parameters. It will then create a new HttpServletRequest
with the parameters provided in memory and ask the RequestDispatcher
to include the resource with the given path.
{% render '/hello' with {name: 'Jtwig'} %}
The example above will make a call to render the servlet listening on the path /hello
with the GET parameters name=Jtwig
.
Configuration
As shown below, the configuration of this extension is none. One just need to pass it on to the Environment configuration so it will be used.
EnvironmentConfigurationBuilder.configuration()
.extensions().add(new RenderExtension()).and()
.build()
Integration
Integrating Jtwig Render Extension on your project is quite simple with the help of dependency managers. To check the most recent version, go to bintray.
Gradle
repositories {
jcenter()
}
dependencies {
compile 'org.jtwig:jtwig-render-extension:1.X'
}
Maven
<repositories>
<repository>
<id>bintray</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jtwig</groupId>
<artifactId>jtwig-render-extension</artifactId>
<version>1.X</version>
</dependency>
</dependencies>
Examples
Check the jtwig-examples project on github for examples using this render engine.