StringTemplate Renderer for JPublish, a Component this time ;)
Hi there,
For those of you maintaining JPublish sites developed with Velocity or FreeMarker, using the newly added StringTemplate renderer is not an easy option, especially if those sites are in production. So what can you do if you want to use ST?
Don't worry, you can render StringTemplate syntax in Velocity/FreeMarker driven pages by using the StringTemplate component that I just added to the JPublish component family.
Using it is very simple.
Build the ST Component from SVN and load it in jpublish.xml:
<component-manager>
<components>
<component id="JPST" classname="ca.flop.jpublish.components.JPSTComponent">
<stringtemplate-groups>
<group name="default" relative-root-dir="/st_content" refresh-interval="15"
lexer="org.antlr.stringtemplate.language.DefaultTemplateLexer"/>
<group name="menus" relative-root-dir="/st_menus"/>
</stringtemplate-groups>
</component>
</components>
</component-manager>
and then use the ST component wherever ST is required, for example in a Velocity page:
$components.JPST.renderPath("menus:main_menu"), the contents of the main_menu.st file will be immediately rendered in-line.
I will add more details in the JPublish Wiki, meanwhile you can find the code and a demo web application in our SVN.
Have fun!
-florin
Re: StringTemplate Renderer for JPublish, a Component this time ;)
Oh, Oh, oh ... I know you believe that #set or similar instructions in the template languages are instructions coming from Hell :) and as I said, ST compared with Velocity or Freemarker represents the *real* and the pure separation of roles and concerns between the presentation layer and the app logic (controller and model). ST follows a perfect theory. However, in the day-by-day practice, sometimes being able to commit small sins in a pure world is very common to humans, therefore I believe #set or similar instructions are acceptable ;)
