Changeset 66 in text-formbuilder for trunk/lib


Ignore:
Timestamp:
03/11/05 15:17:59 (20 years ago)
Author:
peichman
Message:

worked on the rules for parsing lists in the grammar
allow end of field line comments
growable fields can specify a limit; e.g. "person*4" to limit to 4
use '+other' to specify that a field should have an 'Other' option (FB 3.02)
rearranged TODOs in the main documentation

Location:
trunk/lib/Text
Files:
2 edited

Legend:

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

    r64 r66  
    77use vars qw($VERSION @EXPORT); 
    88 
    9 $VERSION = '0.09'; 
     9$VERSION = '0.10'; 
    1010@EXPORT = qw(create_form); 
    1111 
     
    241241        defined $$field{$_} or delete $$field{$_} foreach keys %{ $field }; 
    242242         
    243         unless ($FB_version >= '3.002') { 
    244             if ($$field{growable}) { 
    245                 warn '[' . (caller(0))[3] . "] growable fields not supported by FB $FB_version (requires 3.002)"; 
    246                 delete $$field{growable}; 
     243        unless ($FB_version >= '3.02') { 
     244            for (qw(growable other)) { 
     245                if ($$field{$_}) { 
     246                    warn '[' . (caller(0))[3] . "] '$_' fields not supported by FB $FB_version (requires 3.02)"; 
     247                    delete $$field{$_}; 
     248                } 
    247249            } 
    248250        } 
     
    509511                    $OUT .= qq[<th></th>]; 
    510512                } else { 
    511                     $OUT .= '<th class="label">' . ($$_{required} ? qq[<strong class="required">$$_{label}:</strong>] : "$$_{label}:") . '</th>'; 
     513                    $OUT .= '<th class="label">' . ($$_{required} ? qq[<strong class="required">$$_{label}</strong>] : "$$_{label}") . '</th>'; 
    512514                } 
    513515                 
     
    11601162=head1 TODO 
    11611163 
    1162 Document the commmand line tool 
     1164=head2 Documentation/Tests 
    11631165 
    11641166Document use of the parser as a standalone module 
     1167 
     1168Better tests! 
     1169 
     1170=head2 Language/Parser 
    11651171 
    11661172Allow renaming of the submit button; allow renaming and inclusion of a  
     
    11721178validate. These should cause C<build> to emit a warning before ignoring them. 
    11731179 
     1180C<!include> directive to include external formspec files 
     1181 
     1182=head2 Code generation/Templates 
     1183 
     1184Alternative format using C<< <fieldset> >> tags instead of C<< <h2> >> 
     1185section headers 
     1186 
    11741187Make the generated modules into subclasses of CGI::FormBuilder 
     1188 
     1189Better integration with L<CGI::FormBuilder>'s templating system 
    11751190 
    11761191Allow for custom wrappers around the C<form_template> 
     
    11781193Maybe use HTML::Template instead of Text::Template for the built in template 
    11791194(since CGI::FormBuilder users may be more likely to already have HTML::Template) 
    1180  
    1181 C<!include> directive to include external formspec files 
    1182  
    1183 Better tests! 
    11841195 
    11851196=head1 BUGS 
  • trunk/lib/Text/FormBuilder/grammar

    r64 r66  
    1 {  
     1{ 
     2    #$::RD_TRACE = 1; 
    23    my ( 
    34        $context,      # line or group 
     
    5657    { $lists{$item{var_name}} = [ @options ]; @options = () } 
    5758 
    58 static_list: '{' option(s /,\s*/) /,?/ '}' 
     59static_list: '{' /\s*/ option(s /\s*,\s*/) /,?/ /\s*/ '}' 
    5960 
    6061dynamic_list: '&' <perl_codeblock> 
     
    160161 
    161162# this is the real heart of the thing 
    162 field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) 
     163field: name field_size(?) growable(?) label(?) hint(?) type(?) other(?) default(?) option_list(?) validate(?) comment(?) 
    163164    { 
    164165        my $field = { 
    165166            name     => $item{name}, 
    166             growable => ($item{'growable(?)'}[0] ? 1 : 0), 
     167            growable => $item{'growable(?)'}[0], 
    167168            label    => $item{'label(?)'}[0], 
    168169            comment  => $item{'hint(?)'}[0], 
    169170            type     => $item{'type(?)'}[0], 
     171            other    => $item{'other(?)'}[0], 
    170172            value    => $item{'default(?)'}[0], 
    171173            list     => $list_var, 
     
    214216    { $rows = $item[1]; $cols = $item[3] } 
    215217 
    216 growable: '*' 
     218growable: '*' limit(?) { $item{'limit(?)'}[0] || 1 } 
     219 
     220limit: /\d+/ 
    217221 
    218222label: '|' (simple_multiword | quoted_string) { $item[2] } 
     
    224228builtin_field: /textarea|text|password|file|checkbox|radio|select|hidden|static/ 
    225229 
     230other: '+' 'other' { 1 } 
    226231 
    227232default: '=' (simple_multiword | quoted_string) { $item[2] } 
    228233 
    229234# for simple multiword values not involving punctuation 
    230 simple_multiword: <skip:''> /[\w\t ]+/ { $item[2] } 
     235simple_multiword: <skip:''> /\w[\w\t ]+/ { $item[2] } 
    231236 
    232237# my attempt at a single-quoted, non-interpolating string 
     
    237242option_list: options | list_var 
    238243     
    239 options: '{' option(s /,\s*/) '}' 
     244options: '{' option(s /,/) '}' 
    240245 
    241246list_var: /@[A-Z_]+/ { $list_var = $item[1] } 
    242247 
    243 option: (simple_multiword | value | quoted_string) display_text(?) 
     248option: (simple_multiword | quoted_string) display_text(?) 
    244249    { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 
    245250 
Note: See TracChangeset for help on using the changeset viewer.