Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

generating html from a template

by jimbus (Friar)
on Oct 04, 2005 at 21:29 UTC ( #497413=perlquestion: print w/replies, xml ) Need Help??
jimbus has asked for the wisdom of the Perl Monks concerning the following question:


I'm sure this is a common perl type task, but I'm not sure what to call the pattern so as to google for it...

I want to use perl to generate WML files from a template, using data from an outside source to fill in tokens in the template, eg: funmail.url.beta, I'm in a situation where I'm maintaining 6 decks or sites in beta and production trim with various subsets of production and verification URLs in each. Right now, when I get a new URL or marketing want to shuffle things, I edit things by hand for beta, get approval for promotion after testing, edit in the production URLs by hand for gamma, test again and copy gamma to production

So that's the set up, what I'm asking is: is there a standard format or package for inserting things appropriate places into templates? I think I've seen something like ${funmail.url.beta}, but I thought I would seek you collective wisdom before I headed off in a random direction.



Never moon a werewolf!

Replies are listed 'Best First'.
Re: generating html from a template
by davidrw (Prior) on Oct 04, 2005 at 21:37 UTC
    Two very popular and common templating modules are Template Toolkit and HTML::Template -- i would start by looking at both of those.. Template Toolkit (tt) is quite powerful, and has a (default) syntax like:
    This is my file. Hello, [% first_name %]. You have [% rows.size %] items: [% FOREACH row = rows %] Name: [% %] ; Color = [% row.color %] [% 'Wow!!!' IF ro +w.color == 'red' %] [% END %]
Re: generating html from a template
by CountZero (Bishop) on Oct 04, 2005 at 21:40 UTC
    Have a look at the various templating packages. I personally like very much Template::Toolkit: I find it very flexible, easy to learn and it has lots of additional extensions.


    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://497413]
Approved by GrandFather
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2018-01-21 17:15 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (228 votes). Check out past polls.