HTML::Mason::Forms - Mason extension for luser-safe component syntax
use HTML::Mason::Forms;
use HTML::Mason;
my $parser = new HTML::Mason::Parser
(
taint_check=>1,
'preprocess'=>\&HTML::Mason::Forms::preprocess,
....
);
HTML::Mason::Forms is a Mason pre-processor that adds some luser-safe HTML-like syntax to Mason components.
This is a wraper around mc_comp(). The SRC attribute is the
component file name, all other attributes are given as arguements to the
component. The code above is equivalent to the following.
%mc_comp(``header.mason'', title=>``Hello world'', root=>``..'');
Short cut for text input. This will output an <INPUT> that will take it's current value from $ARGS, with the VALUE
attribute as default. Additionnaly, the variable $e_mail is
created via the <%args>
The code above is equivalent to the following:
<%args>
${e-mail}="your@email.com"
</%args>
<INPUT type=input name="e-mail" value="<%$e_mail%>">
Note that the name ``e-mail'' is changed into a valid Perl identifier
($e_mail). And that $e_mail isn't HTML escaped.
Similar short cut as <INPUT type=text> above
The code above is equivalent to the following:
<%args>
${don't show}="your password"
</%args>
<INPUT type=input name="don't show" value="<%$don_t_show%>">
Short cut for check boxes. This will output an <INPUT> that will be CHECKED if it was set in $ARGS. If you want it
CHECKED as a default, included the CHECKED attribute in the tag.
Additionnaly, the variable %meal is created via the <%args>
An example
<%INPUT type=checkbox name=meal value=``breakfast''> Breakfast<BR> <INPUT type=checkbox name=meal value=``lunch'' CHECKED> Lunch<BR> <INPUT type=checkbox name=meal value=``tea''> Tea <BR> <INPUT type=checkbox name=meal value=``supper'' CHECKED> Supper<BR>
Is equivalent to
<%args>
%meal=>(supper=>1, lunch=>1)
</%args>
<INPUT type=checkbox name="meal" value="breakfast" <%exists $meal{breakfast} ? ' CHECKED' : ''%>> Breakfast<BR>
<INPUT type=checkbox name="meal" value="lunch" <%exists $meal{lunch} ? ' CHECKED' : ''%>> Lunch<BR>
<INPUT type=checkbox name="meal" value="tea" <%exists $meal{tea} ? ' CHECKED' : ''%>> Tea<BR>
<INPUT type=checkbox name="meal" value="supper" <%exists $meal{supper} ? ' CHECKED' : ''%>> Supper<BR>
Short cut for radio buttons. This will output an <INPUT> that will be CHECKED if it was set in $ARGS. If you want it
CHECKED as a default, included the CHECKED attribute in the tag. If more
then one CHECKED tag is present the first one is used. Additionnaly, the
variable $city is created via the <%args>
An example
<INPUT type=radio name=city value=``mtl'' CHECKED> Montré<BR> <INPUT type=radio name=city value=``qc''> Québec <BR> <INPUT type=radio name=city value=``lvl''> Laval<BR>
Is equivalent to
<%args>
$city=>"mtl"
</%args>
<%INPUT type=radio name=city value="mtl"<%($city||'') eq 'mtl' ? ' CHECKED ' : ''$>>
Montré<BR>
<%INPUT type=radio name=city value="qc"<%($city||'') eq 'qc' ? ' CHECKED ' : ''$>>
Québec <BR>
<%INPUT type=radio name=city value="lvl"<%($city||'') eq 'lvl' ? ' CHECKED ' : ''$>>
Laval<BR>
Philip Gwyn, mason@artware.qc.ca
HTML::Mason, HTML::Mason::Parser