[Templates] Wrap text in an HTML tag
Ronald J Kimball
rkimball+tt at pangeamedia.com
Mon Feb 11 17:03:11 GMT 2008
I'm trying to figure out the best way to wrap part of a string text in
an HTML tag. The string will be the result of calling
Catalyst.localize(), using the quant command for pluralization.
For example:
[% Catalyst.localize('You have [quant,_1,new message].',
new_message_count) %]
Output:
You have 2 new messages.
Desired:
You have <span class="highlight">2</span> new messages.
I looked at the replace() filter, but the replace string is a literal
string, so [% ... | replace('\d+', '<span class="highlight">$1</span>')
doesn't work.
It seems I'll need to create a custom filter to handle this, but I was
curious if anyone else had a suggestion.
thanks,
Ronald
More information about the templates
mailing list