<% @conf
main.JostracaVersion = 0.4
main.TemplateScript = java
%>
<% @init
_setFullFileName( "Replacements.txt" );
String person = "Bob";
%>
<% @replace Person $<o>=person$<c> %>
Hello Person!
Bye Person!
Watch out when the replacement is contained
in another word, like 'Personal'.
<%--
How to make a repeated area of text more readable.
Note: longer replacements take precedence,
so that //-foreach-Name-// does not become //-foreach-Bob-//
--%>
<% String[] names = new String[] { "Bob", "Fred", "John" }; %>
<% @replace //-foreach-Name-// '$<o> for( int nameI = 0; nameI < names.length; nameI++ ) { $<c>' %>
<% @replace Name $<o>=names[nameI]$<c> %>
<% @replace //-end-// '$<o> } $<c>' %>
//-foreach-Name-//
Hi Name
//-end-//
<%-- How to define a custom template language --%>
<% @replace-regexp #if\s(.*?)\n $<o>if($1){$<c> %>
<% @replace #else $<o>}else{$<c> %>
<% @replace #end $<o>}$<c> %>
#if "Bob".equals( person )
Hi Bob!
#else
this will not appear
#end
|