I'm sure this is answered somewhere in the docs, but I can't find it (I'm curious why Google returns no matches when doing a site: search on http://template-toolkit.org).

When I use a Template Toolkit plugin -- [% USE my_plugin %] -- how can a plugin determine its own name? I am building stuff that uses plugins in some strange ways and it would be helpful if a plug can "self-identify". I started out by doing something like the following:

[% USE my_plugin "some_identifier" %]

However, having to pass that identifier every time means a chance for a typo every time. Further, if a plugin presents a form and later handles the form data (these are Web-based apps I'm working with), I need it to be able to send the user to another page with the same plugin handling the data. Passing the ID in the template means I have to synchronize the ID across templates: not good. Hard-coding the ID into every plugin means one more thing that programmers have to remember, so that's also not a good alternative.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Runtime determination of TT plugin name by Ovid

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.