Hello everybody.

I have a module here I've been working on that generates Perl code from templates for a purpose particular to its domain.

I'm using the Template Toolkit for my templates and I'm very happy with that. I've got the templates themselves in a subdir called /root.

Now all is well when working locally but I want users to be able to unpack and install my module and the module have access to the templates to do its work.

How might this be possible? Well, I know from the TT docs that Template::Config provides the instdir method which lets you find the location of your TT2 installation and that there's a templates directory there. So maybe some tinkering with the Makefile could get them installed...

...but hang on: what if the module gets installed by someone without superuser privileges or in a non-standard environment for testing purposes?

I note that Maypole/Catalyst have TT2 templates as part of the distribution and have gone down the path of telling you to copy them into your derived application. Is there a tidier way?

Obviously, it's occurred to me to inline them in Perl HEREDOCs but that's not very tidy and I wondered if anyone could do better?


MB

In reply to Including TT2 templates in module distributions by matthewb

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.