> I fixed the problem by stringing the replace statements (which I didn't
> know I could do, but just seemed like the Right thing to do)
> ie:
>
> [% MACRO unescape(text)
> text.replace('{b}', '<b>').replace('{/b}', '</b>').replace('{i}',
> '<i>').replace('{/i}', '</i>').etc..
> %]

Larry and Andy are both right, but Andy is righter :)  Larry fixed your 
original code to work as a MACRO, but it still left the bug in it that it 
would print your text three times.  The replace vmethod in TT works like the 
replace method in javascript in that the original string is not modified, but 
a modified version is returned.  In your case you replaced three times so it 
would print out three times.

perl -e '
my $s = q{[% a="b"; c=a.replace("b","d"); "a=$a, c=$c" %]};
use Template; Template->new->process(\$s); print "\n"'

prints
a=b, c=d

Changing to the chaining method makes it so that you only end up with one 
result.  Andy's amendment of adding GET to your solution results in the 
proper MACRO getting created.

But you probably know this all by now anyway.

Paul

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to