http://www.perlmonks.org?node_id=417710


in reply to Re: mini-languages for MVC view/controller manipulation
in thread mini-languages for MVC view/controller manipulation

Pshaw.

Your "shown here" link doesn't seem to work, but the example you give above is not very convincing.

You are perfectly free to use standard Perl argument passing conventions with your Mason components:

<& my_component, $foo, $bar, $baz &> ...
my ( $foo, $bar, $baz ) = @_; ...

The <%args> block is an optional extra mechanism for retrieving arguments, which you don't need to use if it makes you paranoid.

The @elements line in an <%args> block is equivalent to something like my %ARGS = @_; my @elements = @{ $ARGS{elements} || croak("Missing required argument: elements" }. That's a useful shortcut, particularly after you factor in the support for default values, but again, it's layered on top of the normal mechanism, not a replacement for it.

I think that in constrained contexts, mini-languages and format strings can be quite useful; the succinctness allows the developer to work at a higher level. I find them particularly non-threatening in cases like HTML::Mason, where all of the mini-language code is translated to pure Perl before execution -- just look at your var/obj directory to see exactly what Perl code was produced for an %args block or other HTML::Mason markup.

If you've made up your mind that you only want to use "pure" Perl syntax, feel free to use heredocs and interpolation tricks to generate your page templates, but I think most developers would agree that this is a case in which an additional layer with a different syntax is justified.

Replies are listed 'Best First'.
Re^3: mini-languages for MVC view/controller manipulation
by metaperl (Curate) on Dec 28, 2004 at 21:37 UTC
    If you've made up your mind that you only want to use "pure" Perl syntax,
    Yes, I have: meta-level (Perl) manipulation of object-level (HTML) is my credo.
    feel free to use heredocs and interpolation tricks to generate your page templates,
    May I use HTML::Seamstress as part of my heresy? ;-)