I don't know if Template-Toolkit offers such an option (I assume you have searched for one already, and haven't found one), but it shouldn't be very hard to do it by yourself.

From the syntax exmples in the docs it seems you only have to parse

[% PROCESS template var=val var=val ... %] [% INCLUDE template var=val var=val ... %]

Since there's no tag nesting, it can be done with regexes.

A first ad-hoc attempt, not tested:

my $re = qr{ \[%-? # start tag \s* (?:PROCESS|INCLUDE) \s+ (\S+) # template name .*? # any parameters you're not interested in -?%\] # end tag }xs;

Try if it matches all you need, if not refine it.

And yes, that's only an ad-hoc solution, and wo't scale very well.

(Update: template name is probably \S+, \w+ is too restrictive)


In reply to Re: Template Toolkit "Pre-Processor" by moritz
in thread Template Toolkit "Pre-Processor" by hogsmill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.