This is likely a trivial question, but I am a novice and the answer eludes me. I am using Template Toolkit to process some ... err, templates. Nothing fancy, just passing a reference to a one dimensional hash, the keys match the template variable names, and it spits out exactly what I expect. So on to some more templates, these provided by a 3rd party. I want to use the templates for my output, but the template variable names no longer match my hash keys.

Basically I'm going to be mapping (perhaps not the best word) my hash keys to the 3rd party template variables that are their equivalent. (last_name vs. lname for instance) My question at this time is not related to that particular task, however. My question is....

Does Template Toolkit provide access to the data structure of a parsed template? I already know the names of the keys in my hash, what I want is to be able to fetch out all of the variable names in a simple template and create some logic that can translate my keys to the appropriate template variable.

A nudge in the right direction would suffice. I'm quite sure I am overlooking something obvious.


In reply to Parse template into data structure by Anonymous Monk

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.