- Timestamp:
- 10/06/04 13:44:15 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Text/FormBuilder.pm
r1 r7 4 4 use warnings; 5 5 6 our $VERSION = '0.0 1';6 our $VERSION = '0.02'; 7 7 8 8 use Text::FormBuilder::Parser; 9 9 use CGI::FormBuilder; 10 use YAML;11 10 12 11 sub new { … … 153 152 } 154 153 155 sub _dump { print YAML::Dump(shift->{form_spec}); } 154 sub 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 } 156 162 157 163 … … 170 176 # returns a new CGI::FormBuilder object with the fields 171 177 # from the input form spec 172 my $form = $parser-> build_form;178 my $form = $parser->form; 173 179 174 180 =head1 DESCRIPTION … … 178 184 =head2 parse 179 185 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 180 193 =head2 build 181 194 195 Options passed to build are passed on verbatim to the L<CGI::FormBuilder> 196 constructor. Any options given here override the defaults that this module 197 uses. 198 199 =head2 form 200 201 my $form = $parser->form; 202 203 Returns the L<CGI::FormBuilder> object. 204 182 205 =head2 write 183 206 207 $parser->write($out_file); 208 # or just print to STDOUT 209 $parser->write; 210 211 Calls C<render> on the FormBuilder form, and either writes the resulting HTML 212 to a file, or to STDOUT if no filename is given. 213 214 =head2 dump 215 216 Uses L<YAML> to print out a human-readable representaiton of the parsed 217 form spec. 218 184 219 =head1 LANGUAGE 185 220 186 name[size]|descriptive label[hint]:type=default{option1 (display string),option2(display string),...}//validate221 name[size]|descriptive label[hint]:type=default{option1[display string],option2[display string],...}//validate 187 222 188 223 !title ... … … 190 225 !pattern name /regular expression/ 191 226 !list name { 192 option1 (display string),193 option2 (display string),227 option1[display string], 228 option2[display string], 194 229 ... 195 230 } … … 204 239 205 240 =item C<!title> 241 242 =item C<!author> 206 243 207 244 =back … … 220 257 Any line beginning with a C<#> is considered a comment. 221 258 259 =head1 TODO 260 261 =head2 Langauge 262 263 Directive for a descriptive or explanatory paragraph about the form 264 265 Subsection headers? 266 222 267 =head1 SEE ALSO 223 268
Note: See TracChangeset
for help on using the changeset viewer.