Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am using Template Toolkit to generate HTML code. It is used inside a loop. First time (first iteration) works ok, but next it does not do anything. Here it is Perl code

my $headers = HTTP::Headers->new; $headers->header('Content-Type' => 'text/html;charset=UTF-8'); print $headers->as_string; my $template = Template->new({ INCLUDE_PATH => some path, INTERPOLATE => 1, }) || do { my $error = $Template::ERROR; my $q = new CGI; error($q, "Caught error: " . $error); }; my $link = ""; foreach my $key (keys %referencesData) { $link = $referencesData{$key}; # Here it is where html is invoked and first iteration works ok, b +ut next it does not do anything $template->process('template.ttml', { link => $link } ) || do { my $error = $template->error(); my $q = new CGI; error($q, "Caught error: " . $error); }; }

And here it is ttml code

[%# template.ttml %] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <head> <TITLE>Some title</TITLE> <meta http-equiv="refresh" content="$link" /> </head> <body> <center> </center> <form action=""> </form> </body> </html>

As I mentioned, it works ok in first iteration, but next one it seems it does not do anything. What seems to be the trouble?


In reply to Doubt about Template Toolkit by logangha

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found