Are you saying that I'd have to break up all of my modules and put the subroutines into their own files with a .tt extension? So, I'd have to break up my Base::HTML where most of the base code for my site lives?

:| Are you calling me Shirley? |:

:|

Note the lack of humor in my facial expression ;D

Organizing templates in separate files is the most natural way to do it, but you're not limited to that approach

When you said tt2 would not do the templating you need, I assumed you couldn't find the argument passing portion of the manual, so I showed you a simple example, was I wrong?

If you wish to use Base::HTML from TT2 you could make a plugin

[% USE BaseHTML; # Template::Plugin::BaseHTML.pm GET BaseHTML.print_definitions( file => "some_file_a.txt", headings => [ "term", "definition" ], ); %]

Here is a running example

$ cat dumper.tt [% USE Dumper Indent = 1; GET Dumper.dump( file => "some_file_a.txt", headings => [ "term", "definition" ], ) %] $ tpage dumper.tt $VAR1 = { 'file' => 'some_file_a.txt', 'headings' => [ 'term', 'definition' ] };

Or you could use the Class plugin, simple running example

$ cat class.tt [% USE q = Class('CGI'); GET q.start_form(); %] $ tpage class.tt <form method="post" action="http://localhost" enctype="multipart/form- +data">

If the OOP-yness of Template::Plugin::Class doesn't quite work for you (since your base doesn't appear to be OO), its easy to modify to Template::Plugin::Class::Proxy::AUTOLOAD to remove $self

See also Template::Plugin, Template::Plugin::, Template::Plugin::Dumper, , Template::Plugin::Class, Template::Provider::Preload, Template::Provider::MD5, Template::Provider::Memory


In reply to Re^5: Evaluating subroutines from within data by Anonymous Monk
in thread Evaluating subroutines from within data by Lady_Aleena

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.