Changeset 66 in text-formbuilder for trunk/lib/Text
- Timestamp:
- 03/11/05 15:17:59 (20 years ago)
- Location:
- trunk/lib/Text
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder.pm
r64 r66 7 7 use vars qw($VERSION @EXPORT); 8 8 9 $VERSION = '0. 09';9 $VERSION = '0.10'; 10 10 @EXPORT = qw(create_form); 11 11 … … 241 241 defined $$field{$_} or delete $$field{$_} foreach keys %{ $field }; 242 242 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 } 247 249 } 248 250 } … … 509 511 $OUT .= qq[<th></th>]; 510 512 } 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>'; 512 514 } 513 515 … … 1160 1162 =head1 TODO 1161 1163 1162 Document the commmand line tool 1164 =head2 Documentation/Tests 1163 1165 1164 1166 Document use of the parser as a standalone module 1167 1168 Better tests! 1169 1170 =head2 Language/Parser 1165 1171 1166 1172 Allow renaming of the submit button; allow renaming and inclusion of a … … 1172 1178 validate. These should cause C<build> to emit a warning before ignoring them. 1173 1179 1180 C<!include> directive to include external formspec files 1181 1182 =head2 Code generation/Templates 1183 1184 Alternative format using C<< <fieldset> >> tags instead of C<< <h2> >> 1185 section headers 1186 1174 1187 Make the generated modules into subclasses of CGI::FormBuilder 1188 1189 Better integration with L<CGI::FormBuilder>'s templating system 1175 1190 1176 1191 Allow for custom wrappers around the C<form_template> … … 1178 1193 Maybe use HTML::Template instead of Text::Template for the built in template 1179 1194 (since CGI::FormBuilder users may be more likely to already have HTML::Template) 1180 1181 C<!include> directive to include external formspec files1182 1183 Better tests!1184 1195 1185 1196 =head1 BUGS -
trunk/lib/Text/FormBuilder/grammar
r64 r66 1 { 1 { 2 #$::RD_TRACE = 1; 2 3 my ( 3 4 $context, # line or group … … 56 57 { $lists{$item{var_name}} = [ @options ]; @options = () } 57 58 58 static_list: '{' option(s /,\s*/) /,?/ '}'59 static_list: '{' /\s*/ option(s /\s*,\s*/) /,?/ /\s*/ '}' 59 60 60 61 dynamic_list: '&' <perl_codeblock> … … 160 161 161 162 # this is the real heart of the thing 162 field: name field_size(?) growable(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?)163 field: name field_size(?) growable(?) label(?) hint(?) type(?) other(?) default(?) option_list(?) validate(?) comment(?) 163 164 { 164 165 my $field = { 165 166 name => $item{name}, 166 growable => ($item{'growable(?)'}[0] ? 1 : 0),167 growable => $item{'growable(?)'}[0], 167 168 label => $item{'label(?)'}[0], 168 169 comment => $item{'hint(?)'}[0], 169 170 type => $item{'type(?)'}[0], 171 other => $item{'other(?)'}[0], 170 172 value => $item{'default(?)'}[0], 171 173 list => $list_var, … … 214 216 { $rows = $item[1]; $cols = $item[3] } 215 217 216 growable: '*' 218 growable: '*' limit(?) { $item{'limit(?)'}[0] || 1 } 219 220 limit: /\d+/ 217 221 218 222 label: '|' (simple_multiword | quoted_string) { $item[2] } … … 224 228 builtin_field: /textarea|text|password|file|checkbox|radio|select|hidden|static/ 225 229 230 other: '+' 'other' { 1 } 226 231 227 232 default: '=' (simple_multiword | quoted_string) { $item[2] } 228 233 229 234 # for simple multiword values not involving punctuation 230 simple_multiword: <skip:''> / [\w\t ]+/ { $item[2] }235 simple_multiword: <skip:''> /\w[\w\t ]+/ { $item[2] } 231 236 232 237 # my attempt at a single-quoted, non-interpolating string … … 237 242 option_list: options | list_var 238 243 239 options: '{' option(s /, \s*/) '}'244 options: '{' option(s /,/) '}' 240 245 241 246 list_var: /@[A-Z_]+/ { $list_var = $item[1] } 242 247 243 option: (simple_multiword | value |quoted_string) display_text(?)248 option: (simple_multiword | quoted_string) display_text(?) 244 249 { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 245 250
Note: See TracChangeset
for help on using the changeset viewer.