On Sat, Nov 29, 2003 at 09:35:37AM +0000, Andy Wardley wrote:
> Jesse Sheidlower wrote:
> > What's the more TT-ly way of doing this?
["this" = precede a particular word with an image ]
> [% FILTER replace('foo', '<img src="...">foo') %]
> your content here...
> [% END %]
Thanks. How would I do so in a case-insensitive manner?
If I have the variables "match" for the match term,
and "img" for the image, then
[% text = text | replace("$match","${img}${match}") %]
will only work if $match and the match in $text have
the same case. Making the first element of the replace
into "\L$match" doesn't work at all, but even if it
did, I wouldn't want to replace $text with a different-
cased version of $match.
In my original I had
$text =~ s/($match)/$img$1/ig;
so I could rely on the /i to match case-insensitively
and the $1 to maintain the same form of the text; can
I replicate this with TT?
Thank you.
Jesse Sheidlower
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates