NAME

HTML::Mason::Forms - Mason extension for luser-safe component syntax


SYNOPSIS

    use HTML::Mason::Forms;
    use HTML::Mason;
    my $parser = new HTML::Mason::Parser 
            (
                taint_check=>1, 
                'preprocess'=>\&HTML::Mason::Forms::preprocess,
                ....
            );


DESCRIPTION

HTML::Mason::Forms is a Mason pre-processor that adds some luser-safe HTML-like syntax to Mason components.

<%MASON src="header.mason" title="Hello world" root="..">

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=>``..'');
<%INPUT type=input name="e-mail" value="your@email.com">

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.

<%INPUT type=passwd name="don't show" value="your password">

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%>">
<%INPUT type=checkbox name=meal value=supper>

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>
<%INPUT type=radio name=city value="Montr&amp;eacute;al">

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&eacute;<BR> 
<INPUT type=radio name=city value=``qc''> Qu&eacute;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&eacute;<BR>
    <%INPUT type=radio name=city value="qc"<%($city||'') eq 'qc' ? ' CHECKED ' : ''$>> 
    Qu&eacute;bec <BR>
    <%INPUT type=radio name=city value="lvl"<%($city||'') eq 'lvl' ? ' CHECKED ' : ''$>> 
    Laval<BR>

AUTHOR

Philip Gwyn, mason@artware.qc.ca

SEE ALSO

HTML::Mason, HTML::Mason::Parser