First thanks for a great and very useful module. I have recently started using it over my own module which provided a very small subset of the functionality of HTML::Template.
However there is one thing I am either missing or don't see how to make it work... I want to be able to cast results on a loop template incrementaly. That is I would like to say:
$template->param('LOOP', [{p1 => v1}]);
and later in the program(probably in a while loop, fetching data from a database):
$template->param('LOOP', [{p1 => v2}]);
and I would expect for a template like that:
<TMPL_LOOP LOOP>
<H1><TMPL_VAR p1></H1>
</TMPL_LOOP>
the following output:
<H1>v1</H1>
<H1>v2</H1>
I think this is a really useful feature if you don't want to build your whole dataset into memory (it may be reallt large) before casting it on the template.
The way I do it in my module is:
When casting a loop param I simply keep the loop tag after every iteration. So after one iteration of the above code I would have:
<H1>v1</H1>
<TMPL_LOOP LOOP>
<H1><TMPL_VAR p1></H1>
</TMPL_LOOP>
Of course you don't want the template commands in your final output. So there is another command that the user has to call named 'finalize(loop_name)' in my case and all it does is remove the template code for the loop named loop_name...
I don't know the internals of HTML::Template so I don't know whether such an approach is feasible. But if it is I really think it should be built in the module...
Thanks for a great module!
giorgos
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi people,
First thanks for a great and very useful module. I have recently started using it over my own module which provided a very small subset of the functionality of HTML::Template.
However there is one thing I am either missing or don't see how to make it work... I want to be able to cast results on a loop template incrementaly. That is I would like to say:
$template->param('LOOP', [{p1 => v1}]);
and later in the program(probably in a while loop, fetching data from a database):
$template->param('LOOP', [{p1 => v2}]);
and I would expect for a template like that:
<TMPL_LOOP LOOP>
<H1><TMPL_VAR p1></H1>
</TMPL_LOOP>
the following output:
<H1>v1</H1>
<H1>v2</H1>
I think this is a really useful feature if you don't want to build your whole dataset into memory (it may be reallt large) before casting it on the template.
The way I do it in my module is:
When casting a loop param I simply keep the loop tag after every iteration. So after one iteration of the above code I would have:
<H1>v1</H1>
<TMPL_LOOP LOOP>
<H1><TMPL_VAR p1></H1>
</TMPL_LOOP>
Of course you don't want the template commands in your final output. So there is another command that the user has to call named 'finalize(loop_name)' in my case and all it does is remove the template code for the loop named loop_name...
I don't know the internals of HTML::Template so I don't know whether such an approach is feasible. But if it is I really think it should be built in the module...
Thanks for a great module!
giorgos
I think this would be very important.