Hi,

Here's what I used to convert our templates, although I think
the result needed some tweaking

#!/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 $name %]";
        } elsif($tag eq 'VAR') {
            $out = "[% $name %]";
        } else { 
            warn "Unknown tag $tag ($close,$name)\n";
        }   
        warn $out;
        $out;
    >gei;

__END__
-- 
 It is written that the priest Shungaku said, "In just refusing to
 retreat from something one gains the strength of two men." This is
 interesting.                -- Hagakure http://bowman.bs/hagakure/



_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to