You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Thomas Åhlen <th...@obidobi.net> on 2001/11/23 09:25:18 UTC
parsing templates multiple times
I need a better way to be able to parse a template multiple times.
In the first parse I want to add static content and in the second parse I
will add the dynamic content.
Today my templates can look something like this:
\\#foreach ( $subnet in $subnets )
<tr>
\\#if ( $subnet.ServiceId == 0 )
<td class="emboss" nowrap align="right">ingen
</td>
\\#else
<td class="emboss" nowrap align="right">
<a href="$module">$subnet</A>
</td>
\\#end
\\#end
this so the # directives won't be removed during the first parse. But this
notation \\# stinks hard since browsers remove one \ when you load a
template and display it in a TEXTAREA. So each time I try to modify a
template through a web page a have to add one \ to each directive.
My suggestion to a better solution
[template]
2#foreach ( $subnet in $subnets )
ewewr
2#end
[template] after first parse
1#foreach ( $subnet in $subnets )
ewewr
1#end
[template] after second parse
#foreach ( $subnet in $subnets )
ewewr
#end
Anyone with the same problem as me?! What about my suggestion, this way you
can get better controll over when the directives should be executed.
Thomas Å
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>