Hi there Monks!
I am trying to use this template system that its supposed to be simple and light, but can't get this simple example to work, I am wondering if anyone here has done any work using this template module or show me please where I am going wrong on my example here:
temp.pl
#!/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 ) ;

temp.tmpl
<?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>
Thanks for looking!

In reply to Template::Simple Help! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.