Changeset 46 in text-formbuilder for trunk/lib/Text


Ignore:
Timestamp:
12/15/04 16:49:51 (20 years ago)
Author:
peichman
Message:

added examples documentation; documented the create_form function; updated README

Location:
trunk/lib/Text
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Text/FormBuilder.pm

    r42 r46  
    77use vars qw($VERSION @EXPORT); 
    88 
    9 $VERSION = '0.07_02'; 
     9$VERSION = '0.07_03'; 
    1010@EXPORT = qw(create_form); 
    1111 
     
    4848 
    4949my $HTML_EXTS   = qr/\.html?$/; 
     50my $MODULE_EXTS = qr/\.pm$/; 
    5051my $SCRIPT_EXTS = qr/\.(pl|cgi)$/; 
    5152 
     
    6162        } else { 
    6263            # write webpage, script, or module 
    63             if ($destination =~ $HTML_EXTS) { 
    64                 $parser->write($destination); 
     64            if ($destination =~ $MODULE_EXTS) { 
     65                $parser->write_module($destination); 
    6566            } elsif ($destination =~ $SCRIPT_EXTS) { 
    6667                $parser->write_script($destination); 
    6768            } else { 
    68                 $parser->write_module($destination); 
     69                $parser->write($destination); 
    6970            } 
    7071        } 
     
    686687karate, and bass guitar. 
    687688 
     689=head1 METHODS 
     690 
    688691=head2 new 
    689692 
     
    886889Uses L<YAML> to print out a human-readable representation of the parsed 
    887890form spec. 
     891 
     892=head1 EXPORTS 
     893 
     894There is one exported function, C<create_form>, that is intended to ``do the 
     895right thing'' in simple cases. 
     896 
     897=head2 create_form 
     898 
     899    # get a CGI::FormBuilder object 
     900    my $form = create_form($source, $options, $destination); 
     901     
     902    # or just write the form immediately 
     903    create_form($source, $options, $destination); 
     904 
     905C<$source> accepts any of the types of arguments that C<parse> does. C<$options> 
     906is a hashref of options that should be passed to C<build>. Finally, C<$destination> 
     907is a simple scalar that determines where and what type of output C<create_form> 
     908should generate. 
     909 
     910    /\.pm$/             ->write_module($destination) 
     911    /\.(cgi|pl)$/       ->write_script($destination) 
     912    everything else     ->write($destination) 
     913 
     914For anything more than simple, one-off cases, you are usually better off using the 
     915object-oriented interface, since that gives you more control over things. 
    888916 
    889917=head1 DEFAULTS 
     
    11511179(since CGI::FormBuilder users may be more likely to already have HTML::Template) 
    11521180 
    1153 Better examples in the docs (maybe a standalone or two as well) 
    1154  
    11551181C<!include> directive to include external formspec files 
    11561182 
     
    11611187Creating two $parsers in the same script causes the second one to get the data 
    11621188from the first one. 
    1163  
    1164 Get the fallback to CGI::FormBuilder builtin lists to work. 
    11651189 
    11661190I'm sure there are more in there, I just haven't tripped over any new ones lately. :-) 
Note: See TracChangeset for help on using the changeset viewer.