Frankly, there's nothing new under the sun with templating. What you've done is pretty much identical to several modules that have been on CPAN for years, like CGI::FastTemplate.
Actually, I was aware that CGI::FastTemplate existed, and it was the only one I could see that worked "identically" to Template::Recall when I submitted to CPAN. It just seemed that CGI::FastTemplate existed in the wrong namespace for a general purpose (perhaps non- web-based) template system, and besides, it hasn't been updated since 1999.In fact, there's no reason you can't use HTML::Template, Text::Template, TT2, etc. in the way you're showing here
Sure. All template systems essentially share the same goal. But there is one definite benefit that I can think of for using Template::Recall over these, at least for simple loops. I mention this in my introduction, regarding an output of row data to a simple table like that in my writeup. Using a pipeline system, you have to iterate over the data twice to output the table. Once when generating the array of hashes, and then again as (say) HTML::Template renders it against <TMPL_LOOP> on the call to print $template->output();. With Template::Recall (and Mason/PHP/JSP), there is no such cost, because you can output the row as soon as you receive it. Template::Recall just does it through a method call, which in my opinion, is cleaner.
My advice is to get over your idea that the view shouldn't contain logic. It's supposed to contain logic -- logic about how to display the data. It may sometimes be convenient to write the view logic in perl, and sometimes in a view-specific shorthand like TT2.
Actually, I've never held the opinion that the view should contain no logic. Substitution in my mind is effectively a part of logic. I just want to put as little logic as possible in the template. You're right, sometimes it may be better to have logic in the templates, for instance where you have a team of advanced designers, but there are plenty of other times where projects are driven by people who prefer to do as much in Perl as possible.
In reply to Re^4: Template modules, logic, and SOC
by arbingersys
in thread Template modules, logic, and SOC
by arbingersys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |