Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Looking for a "Template Engine"

by rovf (Priest)
on Jul 22, 2008 at 11:38 UTC ( [id://699274]=note: print w/replies, xml ) Need Help??


in reply to Re: Looking for a "Template Engine"
in thread Looking for a "Template Engine"

I'm pretty sure that Mason does what you want. eperl also looks like it might be interesting for you.

Hmmm.... From the documentation at CPAN: CONFIGURING MASON. ... This section assumes that you are able to install and configure a mod_perl server, so if I understand it right, it seems to assume that it runs with a web application. And as for eperl, I only found Apache::ePerl, and here it says: The intent is to use this special variant of ePerl for scripts which are directly under control of the webmaster... For the average user you should not use Apache::ePerl. Instead additionally install the regular stand-alone ePerl facility (nph-eperl) for those users. So this too assumes Apache. I looked for nph-eperl, but found nothing on CPAN (and the few references I found on nph-eperl on Google seem to suggest that this too assumes somehow to run under a webserver).

Also it looks as if Mason assumes to be embedded in HTML, though perhaps it will work with other text files too....

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Looking for a "Template Engine"
by AltBlue (Chaplain) on Jul 22, 2008 at 17:16 UTC

    HTML::Mason does not depend on mod_perl, but it can use it ;-)

    Here's your example rendered through Mason:

    #!/usr/bin/perl use strict; use warnings; use HTML::Mason; sub foo { $_[0] + $_[1] } my $template = << 'END'; This is some line. This is a line with some expression: <% foo(3,5) %> % for my $s qw(this that) { This is <% $s %> line % } This is the end END my $output; my $interp = HTML::Mason::Interp->new( out_method => \$output, in_package => __PACKAGE__, ); my $comp = $interp->make_component( comp_source => $template ); $interp->exec($comp); print $output;

    You mentioned you don't care too much about the syntax, that's why I preferred do not show you how to override Mason's default syntax. Check out http://masonhq.com/docs/manual/ if you're interested.

    --
    altblue.

      Thank you for providing the example!!!

      -- 
      Ronald Fischer <ynnor@mm.st>
Re^3: Looking for a "Template Engine"
by moritz (Cardinal) on Jul 22, 2008 at 11:54 UTC
    Also it looks as if Mason assumes to be embedded in HTML, though perhaps it will work with other text files too...

    Most template systems ignore the type of document they are embedded in, mostly it's relevant for choosing the delimiters of the interpreted parts, and for stuff like escaping (which is always optional).

    I have no experience with Mason myself, but I'd guess it's similar there (and I'm quite sure there's also a way to use Mason wihout mod_perl. Just look at the test cases, it has to be tested somehow).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-07-21 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.