Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Evaluating subroutines from within data

by Lady_Aleena (Deacon)
on Jan 08, 2012 at 02:45 UTC ( #946819=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Evaluating subroutines from within data
in thread Evaluating subroutines from within data

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?

Have a cookie and a very nice day!
Lady Aleena


Comment on Re^4: Evaluating subroutines from within data
Select or Download Code
Re^5: Evaluating subroutines from within data
by Anonymous Monk on Jan 08, 2012 at 04:23 UTC

    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

      I might give all of that a look later as soon as I figure out how to achieve what I wanted to originally. I have a full example of what I want to do in Re^2: Evaluating subroutines from within data if you care to take a look. From the looks of it, I would have to start almost from scratch to use any templating which makes me balk.

      Have a cookie and a very nice day!
      Lady Aleena
        From the looks of it, I would have to start almost from scratch to use any templating which makes me balk.

        I don't see why; essentially what you have in that node is already a template. The question is what processes it.


        Improve your skills with Modern Perl: the free book.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946819]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-12-26 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (174 votes), past polls