/**
* This example goes more into block locking magic.
* See example2.tlt for more information.
*/
import ee.mare.indrek.jtlt.*;
import ee.mare.indrek.jtlt.macros.*;
public class Example2 {
public static void main (String[] args) throws Exception
{
// Generate our own context
TemplateContext ctx = new TemplateContext ();
// Register our custom macro
ctx.registerMacro (new SimpleMacro());
// Create generator and instance a template.
TemplateGenerator gen = new TemplateGenerator ("example2.tlt", ctx);
Template tlt = gen.createTemplate();
// Trying to lock in a mixed way
tlt.lock ("sub1");
tlt.replace ("id", "mixed1");
tlt.unlock ();
tlt.lock ("sub2");
tlt.replace ("id", "mixed2");
tlt.unlock ();
tlt.lock ("sub1");
tlt.replace ("id", "mixed3");
tlt.unlock ();
tlt.lock ("sub2");
tlt.replace ("id", "mixed4");
tlt.unlock ();
// The difference between lock_back=lock and lock_front
for ( int i = 0; i < 5; i++ ) {
tlt.lock_back ("counter");
tlt.replace ("id", "" + i);
tlt.unlock ();
}
for ( int i = 5; i < 10; i++ ) {
tlt.lock_front ("counter");
tlt.replace ("id", "" + i);
tlt.unlock ();
}
System.out.println (tlt.toString());
}
}
syntax highlighted by Code2HTML, v. 0.9.1