Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use Template::Simple; my $q = new CGI; #my $tmpl = Template::Simple->new(); my $tmpl = Template::Simple->new( search_dirs => [ ( '/dir') ], ); print header(); my $vars = {}; $vars->{'title'} = 'Template Test'; $vars->{'site_name'} = 'TEST Home Page'; $vars = { header => { date => 'Jan 1, 2008', author => 'Me, myself and I', }, row => [ { first => 'row 1 value 1', second => 'row 1 value 2', }, { first => 'row 2 value 1', second => 'row 2 value 2', }, ], footer => { modified => 'Aug 31, 2006', }, } ; #my $rendered = $tmpl->render( 'templ.tmpl', $vars )|| die $tmpl->erro +r(); $tmpl->add_templates( { demo => 'templ.tmpl' } ) ; $tmpl->compile( 'demo' ) ; my $rendered = $tmpl->render( 'demo', $vars ) ;
Thanks for looking!<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http:// +www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd" <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="application/xhtml+xml; charse +t=utf-8" /> <meta http-equiv="Content-language" content="en-gb" /> <meta name="viewport" content="width=device-width; initial-scale=1.0; +maximum-scale=2.5; user-scalable=1;" /> <title>Temp Test [% title %]</title> </head> <body> <h3>Template Simple</h3> <p><b>[%include title %]</b></p> <br> <p><b>[%INCLUDE site_name%]</b></p> <br><br> [%INCLUDE header%] [%START row%] [%first%] - [%second%] [%END row%] [%INCLUDE footer%] </body> </html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Template::Simple Help!
by NetWallah (Canon) on Dec 23, 2011 at 16:48 UTC | |
by Anonymous Monk on Dec 23, 2011 at 18:37 UTC | |
by NetWallah (Canon) on Dec 23, 2011 at 20:36 UTC | |
by Anonymous Monk on Dec 23, 2011 at 20:58 UTC | |
by NetWallah (Canon) on Dec 23, 2011 at 22:52 UTC | |
|