Jostraca Example: Replace
example index
www.jostraca.org
info@jostraca.org

Description:

This template shows how to use the @replace directive to make your template more readable. The basic idea is to replace insertions of the form <%=foo%> with the pure text: Foo. Notice how the shortcut properties $<o> and $<c> are used to escape the open and close script markers <% and %> in the @replace directive.

Generate Command:

> jostraca Replace.jtm
(you can also use generate.bat or generate.sh)

Generated Files:

Replace.txt
.jostraca/ReplaceWriter.java
.jostraca/ReplaceWriter.class

Experiments:

Try adding a replacement for the variable bar.

Template Contents:

<% @conf 
main.JostracaVersion = 0.4
main.TemplateScript  = java
%>

<% init!
_setFullFileName( "Replace.txt" );
String foo = "oof";
String bar = "rab";
%>
<% @replace Foo $<o>=foo$<c> %>

the value of foo is: Foo
the value of bar is: <%=bar%> 
 

Generated File Contents:

Note: only one generated file is shown




the value of foo is: oof
the value of bar is: rab 
 

   example index
   Copyright © 2000-2002 Richard Rodger License.