Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Thoughts on converting from HTML::Template to Template Toolkit

by bsb (Priest)
on Mar 28, 2006 at 08:21 UTC ( [id://539649]=note: print w/replies, xml ) Need Help??


in reply to Thoughts on converting from HTML::Template to Template Toolkit

Here's some scrappy code I used to convert HTML::Template templates to TT2 some years back, just to help the stragglers along...
#!/usr/bin/perl -p # rough conversion of HTML::Template files to TT2 use strict; s{<(\/)?TMPL_(\S+)\s*(?:(?:NAME=)?['"]?(.*?)['"]?)?>} < #warn "Got ($1) ($2) ($3)\n"; my ($close, $tag, $name) = ($1,uc($2),$3); my $out = ''; if($tag =~ /^IF|UNLESS$/) { $out = $close ? "[% END %]" : "[% $tag $name % +]"; } elsif($tag =~ /^INCLUDE|ELSE$/) { $out = "[% $tag $name %]"; } elsif($tag eq 'LOOP') { $out = $close ? "[% END %]" : "[% FOREACH $nam +e %]"; } elsif($tag eq 'VAR') { $out = "[% $name %]"; } else { warn "Unknown tag $tag ($close,$name)\n"; } warn $out; $out; >gei;
  • Comment on Re: Thoughts on converting from HTML::Template to Template Toolkit
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://539649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-19 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found