In the small app I'm currently working on, I create 3 or 4 template objects and print each of their outputs. Each invocation of these templates is presenting data from unrelated queries.
This is just a suggestion on how this might be managed (and simplified) with one template object:
sub some_mode {
my $tmpl_object = $self->load_tmpl('my_tmpl.html');
$tmpl_object->param( param1 => 'foo'
param2 => 'bar',
param3 => 'baz');
# Poke the data for the top part of the page into the $tmpl_object
get_top($tmpl_object);
# Ditto for the left side of the page
get_left($tmpl_object);
# Display the entire templated page
return $tmpl_object->output;
}
Of course you can add parameters to get_top() and get_left() to fine tune their output on a mode-by-mode basis, but by passing around one template object at a time things may become much simpler than having your program eat its tail calling one recursive mode within a mode within a mode after another.
-
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.
|