in reply to Re^2: Output should have multiple segments
in thread Output should have multiple segments
When I first looked at ASP a good many years ago, that was my reaction too: mixing the code and data is bad, we should be separating it. It's awesome for just dropping in a value in the middle of a paragraph of HTML, and is really no different from how we interpolate in string literals.
But I see that Mason has a few features so you are not forced to mix it to badly. If you decide to use "interpolation" in the same way as with Perl strings, and stick with pre-computed values in variables, and put real code elsewhere: The init section is solid Perl and computes all the needed values.
For repeating lines, you can put a Perl loop around the HTML. In a specialized template notation that is all you could do, but here you could use any Perl any time. But don't. Stick to foreach loops on a % line.
You can also call Mason components from normal Perl expressions, and are not forced to shift gears back and forth to do some computing, emit a component, and compute some more. You could even simply print ordinary Perl strings to the emitted output.
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Output should have multiple segments
by Herkum (Parson) on Jul 16, 2008 at 05:13 UTC | |
by AltBlue (Chaplain) on Jul 19, 2008 at 14:04 UTC |