Bill Moseley wrote:
> I don't suppose such a thing exists.  

No, but it's not too hard to write something that does most of the work.

For example:

  #!/usr/bin/perl -p 
  s{<TMPL_VAR \s+ NAME="(.*?)" \s* /?>}
   {[% $1 %]}gx;
  s{<TMPL_LOOP \s+ NAME="(.*?)">}
   {[% FOREACH $1 %]}gx;
  s{</TMPL_LOOP>}
   {[% END %]}gx;
  s{<TMPL_IF \s+ NAME="(.*?)">}
   {[% IF $1 %]}gx;
  s{<TMPL_ELSE>}
   {[% ELSE %]}gx;
  s{</TMPL_IF>}
   {[% END %]}gx;
  s{<TMPL_UNLESS \s+ NAME="(.*?)">}
   {[% UNLESS $1 %]}gx;
  s{</TMPL_UNLESS>}
   {[% END %]}gx;
  s{<TMPL_INCLUDE \s+ NAME="(.*?)">}
   {[% INCLUDE $1 %]}gx;

Here's an example HTML::Template file:

  blah blah <TMPL_VAR NAME="foo"> blah
  <TMPL_VAR NAME="bar">
  alpha bravo <TMPL_VAR NAME="baz"> charlie
  <TMPL_LOOP NAME="elephant">
  this is the elephant loop
  </TMPL_LOOP>
  <TMPL_INCLUDE NAME="header">
  <TMPL_IF NAME="happy">
  I'm happy
  <TMPL_ELSE>
  You're happy
  </TMPL_IF>
  <TMPL_UNLESS NAME="happy">
  I'm not happy
  </TMPL_UNLESS>

Run it through the ht2tt transmogrifier:

  $ ./ht2tt htfile

Here's the TT2 template spat out:

  blah blah [% foo %] blah
  [% bar %]
  alpha bravo [% baz %] charlie
  [% FOREACH elephant %]
  this is the elephant loop
  [% END %]
  [% INCLUDE header %]
  [% IF happy %]
  I'm happy
  [% ELSE %]
  You're happy
  [% END %]
  [% UNLESS happy %]
  I'm not happy
  [% END %]

HTH
A


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

Reply via email to