/**
* This example demonstrates that template syntax must not be what
* is default. That is if your editor or project or personal taste
* does not like the <!-- and --> you can pick your own
* notation. See example6.tlt for more information.
*/
import ee.mare.indrek.jtlt.*;
import ee.mare.indrek.jtlt.macros.*;
public class Example6 {
public static void main (String[] args) throws Exception
{
TemplateContext ctx = new TemplateContext ();
// We pick and set our own start and end tags.
ctx.setStartTag ("[-");
ctx.setEndTag ("-]");
ctx.setShortcutTags ("KEY", "$(", ")"); // this allows us to use $(keyname)
// Now create a generator with given settings from example6.tlt and instance the template
TemplateGenerator gen = new TemplateGenerator ("example6.tlt", ctx);
Template tlt = gen.createTemplate();
// Replace a single key in current open block
tlt.replace ("hello", "Hello, world!");
// Instance a sub-block named "block"
tlt.instance ("block");
System.out.println (tlt.toString());
}
}
syntax highlighted by Code2HTML, v. 0.9.1