in reply to HTML::Template data types problem
The <TMPL_LOOP> tag allows you to delimit a section of text and give it a name.While this is technically true in some sense, the more important purpose of a TMPL_LOOP is to delimit a section of the template which is to be repeated a variable number of times (thus the name LOOP), with different values filled into its constituent TMPL_VARs on each iteration (and the results all concatenated together).
In other words, if you have a TMPL_LOOP called 'foo', you must assign to the template's 'foo' param an arrayref of things. Each of these things is a hashref of params to use for each iteration when repeatedly filling out the stuff within the TMPL_LOOP (think of HTML::Template recursing multiple times at this point, using only the template text within the TMPL_LOOP section, and calling param using the contents of each hashref). Given the template you provided, I doubt this is what you want -- multiple <body> and <title> tags in your HTML output?
It seems like you grouped the template data in your object's implementation (which is a good idea) by putting them all in a secondary hash called 'content', and then you tried to apply the same named encapsulation to the parts of template. This is not really a great idea here -- HTML::Template doesn't provide a primitive way to do this. Plus, you were just sectioning off pretty much the entire template.
Instead, you can get rid of the TMPL_LOOP from the template, and simply say:
Or even$tmpl->param( title => $self->{content}{title}, body => $self->{content}{body} );
Save TMPL_LOOP for when you have a list of things to display in the template, whose length may vary.. Then when you do use a TMPL_LOOP, its param needs to be assigned an arrayref of hashrefs (not a hashref like $self->{content} as you were using before).$tmpl->param( %{ $self->{content} } );
blokhead
|
|---|