[Templates] Converting from old template language which allows
nested tags into TT template
Josh Rosenbaum
josh@infogears.com
Thu, 19 Oct 2006 10:39:30 -0600
Robin Smidsr=F8d wrote:
> My first initial reaction was to try and remove the inner tags, add a=20
> terminating single quote and use a string concatenation character to=20
> include the output of the embed() function directly into the string. I=20
> researched the mailinglist, but found no string concatenation character=
=20
> in TT. Only some references to "." or "~" that didn't work.
I can help you out on that part:
http://www.template-toolkit.org/docs/plain/Manual/Directives.html#Accessi=
ng_and_Updating_Template_Variables
"You can concatenate strings together using the ' _ ' operator. In Perl 5=
, the '.' is used for string concatenation, but in Perl 6, as in the Temp=
late Toolkit, the '.' will be used as the method calling operator and ' _=
' will be used for string concatenation. Note that the operator must be =
specified with surrounding whitespace which, as Larry says, is construed =
as a feature:"
String concat doesn't work inside parenths, though. ie: abc('test' _ 'abc=
'). So the way you suggested is the only way to really do it in that case=
.
For your other problems: If you don't have many places to fix, I'd just u=
se a regexp to find all the occurrences of these tags and then you can ke=
ep replacing them. Patterns that are used over and over you can do a sear=
ch and replace on using a regexp, saving yourself lots of time. (You coul=
d also output the changes and require that you input "Y" for each one.)
-- Josh