Changeset 7 in text-formbuilder for trunk/lib


Ignore:
Timestamp:
10/06/04 13:44:15 (20 years ago)
Author:
peter
Message:

removed dependecies on YAML and Parse::RecDescent
renamed _dump to dump; now only tries to load YAML if it is called; non-fatal error if YAML cannot be loaded
modified bin/fb-cgi.pl
expanded docs

File:
1 edited

Legend:

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

    r1 r7  
    44use warnings; 
    55 
    6 our $VERSION = '0.01'; 
     6our $VERSION = '0.02'; 
    77 
    88use Text::FormBuilder::Parser; 
    99use CGI::FormBuilder; 
    10 use YAML; 
    1110 
    1211sub new { 
     
    153152} 
    154153 
    155 sub _dump { print YAML::Dump(shift->{form_spec}); } 
     154sub dump {  
     155    eval "use YAML;"; 
     156    unless ($@) { 
     157        print YAML::Dump(shift->{form_spec}); 
     158    } else { 
     159        warn "Can't dump form spec structure: $@"; 
     160    } 
     161} 
    156162 
    157163 
     
    170176    # returns a new CGI::FormBuilder object with the fields 
    171177    # from the input form spec 
    172     my $form = $parser->build_form; 
     178    my $form = $parser->form; 
    173179 
    174180=head1 DESCRIPTION 
     
    178184=head2 parse 
    179185 
     186    $parser->parse($src_file); 
     187     
     188    # or as a class method 
     189    my $parser = Txt::FormBuilder->parse($src_file); 
     190 
     191=head2 parse_text 
     192 
    180193=head2 build 
    181194 
     195Options passed to build are passed on verbatim to the L<CGI::FormBuilder> 
     196constructor. Any options given here override the defaults that this module 
     197uses. 
     198 
     199=head2 form 
     200 
     201    my $form = $parser->form; 
     202 
     203Returns the L<CGI::FormBuilder> object. 
     204 
    182205=head2 write 
    183206 
     207    $parser->write($out_file); 
     208    # or just print to STDOUT 
     209    $parser->write; 
     210 
     211Calls C<render> on the FormBuilder form, and either writes the resulting HTML 
     212to a file, or to STDOUT if no filename is given. 
     213 
     214=head2 dump 
     215 
     216Uses L<YAML> to print out a human-readable representaiton of the parsed 
     217form spec. 
     218 
    184219=head1 LANGUAGE 
    185220 
    186     name[size]|descriptive label[hint]:type=default{option1(display string),option2(display string),...}//validate 
     221    name[size]|descriptive label[hint]:type=default{option1[display string],option2[display string],...}//validate 
    187222     
    188223    !title ... 
     
    190225    !pattern name /regular expression/ 
    191226    !list name { 
    192         option1(display string), 
    193         option2(display string), 
     227        option1[display string], 
     228        option2[display string], 
    194229        ... 
    195230    } 
     
    204239 
    205240=item C<!title> 
     241 
     242=item C<!author> 
    206243 
    207244=back 
     
    220257Any line beginning with a C<#> is considered a comment. 
    221258 
     259=head1 TODO 
     260 
     261=head2 Langauge 
     262 
     263Directive for a descriptive or explanatory paragraph about the form 
     264 
     265Subsection headers? 
     266 
    222267=head1 SEE ALSO 
    223268 
Note: See TracChangeset for help on using the changeset viewer.