Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Template Toolkit Question

by assemble (Friar)
on May 21, 2010 at 13:06 UTC ( #841091=note: print w/replies, xml ) Need Help??

in reply to Template Toolkit Question

The way I do it, I put all my paths and configuration in a module or something like that, so I can access it in Perl. From there, you can make them available in TT by modifying your ->new call like this:

my $tt = Template->new({ INCLUDE_PATH => [ .... '/Users/mysilmaril/Sites/WIW/cgi-bin', '.', ], WRAPPER => 'wrapper', VARIABLES => { IMAGE_URL = "/assets/images", CSS_URL = "/assets/css", STUFF = $Module::Stuff } });

Then you can access them in your template like this:

<html> <head> <link rel="stylesheet" type="text/css" href="[%CSS_URL%]/wiw.css" /> </head> <body> <p>blah blah <img src="[%IMAGE_URL%]/image.png" /> <p>blah blah <p>Something else: [%STUFF%] </body> </html>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://841091]
choroba still has one more.
[Corion]: I have Thursday and Friday off, so then I might get to converting the rough outlines to more articles ;)
[Corion]: But currently, most of the modules are web-related and I don't like to publish two web articles in a row
[Corion]: Maybe I should do the Filter::Simple release on the next weeked - this would give me one more article to milk from this theme

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-04-24 08:53 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (437 votes). Check out past polls.