Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: mini-languages for MVC view/controller manipulation

by metaperl (Curate)
on Dec 27, 2004 at 22:32 UTC ( #417652=note: print w/ replies, xml ) Need Help??


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

Also, passing arguments to a component does not use standard Perl syntax
What I mean by this is shown here. Summarily, even though something is typed as an array or hash:
<%args> @elements %labels </%args>
you end up calling it with references like this:
<& /display, elements => \@some_data, labels => \%data_labels &>
a normal Perl subroutine would use $elements and $labels to receive both.

Whether the Mason syntax is more articulate is not the issue at hand. The issue at hand is that knowing Perl is not enough to receive arguments. You must learn a new calling convention. And when things like this happen, I develop paranoia about what else might be a hair different from what I invested great amounts time and money learning: pure Perl.


Comment on Re: mini-languages for MVC view/controller manipulation
Select or Download Code
Re^2: mini-languages for MVC view/controller manipulation
by simonm (Vicar) on Dec 28, 2004 at 07:14 UTC
    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.

      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? ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417652]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-08-20 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (125 votes), past polls