in reply to Re^2: Output should have multiple segments
in thread Output should have multiple segments
I think a template model like Mason's could benefit from having multiple passes.
That's exactly where we differ. I think that a template system should only do the final pass - convert data structures to text.
Try to think about it this way: if your application has two different views (for example a Template::Toolkit one that produces HTML, and a Mason one that produces XML), how much many of these passes would be duplicate in these two views?
Let's say you have a web application that can produce both HTML pages and PDF files. In both cases you have a table of contents, and for each section you add to the output you also add a line to the table of contents.
If you do the logic for adding that TOC line (which essentially requires either two passes or two output segments) in the template, you duplicate your effort in the two different template systems.
OTOH if your perl code first assembles a data structure that represents the TOC, both of your templates just have to do their job: convert a data structure into text output. No more duplicate logic in there.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Output should have multiple segments
by Jenda (Abbot) on Jul 16, 2008 at 14:36 UTC | |
by moritz (Cardinal) on Jul 16, 2008 at 14:42 UTC | |
by Jenda (Abbot) on Jul 16, 2008 at 22:36 UTC |