RSS feed
<< August 31, 2007 | Home | September 2, 2007 >>

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