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


Ignore:
Timestamp:
10/22/04 10:10:54 (20 years ago)
Author:
peter
Message:

added a !head directive for section headers in forms
removed generated Parser.pm file from version control

Location:
trunk/lib/Text
Files:
1 deleted
2 edited

Legend:

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

    r7 r11  
    9292                TYPE       => 'STRING', 
    9393                SOURCE     => $self->_template, 
    94                 DELIMETERS => [ qw(<% %>) ], 
     94                DELIMITERS => [ qw(<% %>) ], 
    9595            }, 
    9696            data => { 
    97                 author => $self->{form_spec}{author}, 
     97                headings => $self->{form_spec}{headings}, 
     98                author   => $self->{form_spec}{author}, 
    9899            }, 
    99100        }, 
     
    125126  <style type="text/css"> 
    126127    #author, #footer { font-style: italic; } 
    127     th { font-weight: normal; text-align: right; vertical-align: top; } 
     128    th { text-align: left; } 
     129    th h2 { padding: .125em .5em; background: #eee; } 
     130    th.label { font-weight: normal; text-align: right; vertical-align: top; } 
    128131  </style> 
    129132</head> 
     
    135138<% $start %> 
    136139<table> 
    137 <% foreach (@fields) { 
     140<% my $i; foreach(@fields) { 
     141    $OUT .= qq[  <tr><th colspan="2"><h2>$headings[$i]</h2></th></tr>\n] if $headings[$i]; 
    138142    $OUT .= qq[  <tr>]; 
    139     $OUT .= '<th>' . ($$_{required} ? qq[<strong class="required">$$_{label}:</strong>] : "$$_{label}:") . '</th>'; 
    140     $OUT .= qq[<td>$$_{field} $$_{comment}</td></tr>\n] 
     143    $OUT .= '<th class="label">' . ($$_{required} ? qq[<strong class="required">$$_{label}:</strong>] : "$$_{label}:") . '</th>'; 
     144    $OUT .= qq[<td>$$_{field} $$_{comment}</td></tr>\n]; 
     145    $i++; 
    141146} %> 
    142147  <tr><th></th><td style="padding-top: 1em;"><% $submit %></td></tr> 
  • trunk/lib/Text/FormBuilder/grammar

    r10 r11  
    1 { my ($title, $author, %lists, %patterns, @fields, $type, @options, $list_var, $size, $rows, $cols); } 
     1{ my ($title, $author, %lists, %patterns, @fields, @headings, $type, @options, $list_var, $size, $rows, $cols); } 
    22 
    33form_spec: (list_def | line)(s)  
     
    88            lists    => \%lists,  
    99            patterns => \%patterns,  
     10            headings => \@headings, 
    1011            fields   => \@fields, 
    1112        } 
     
    2930list_name: /[A-Z_]+/ 
    3031 
    31 line: <skip:'[ \t]*'> ( title | author | pattern_def | field | comment | blank ) "\n" 
     32line: <skip:'[ \t]*'> ( title | author | pattern_def | heading | field | comment | blank ) "\n" 
    3233 
    3334title: '!title' /.*/ 
     
    4344pattern_name: /[A-Z_]+/ 
    4445pattern: /.*/ 
     46 
     47heading: '!head' /.*/ 
     48    { warn "[Text::FormBuilder] Header before field " . scalar(@fields) . " redefined at input text line $thisline\n" if defined $headings[@fields]; 
     49    $headings[@fields] = $item[2] } 
    4550 
    4651field: name field_size(?) label(?) hint(?) type(?) default(?) option_list(?) validate(?) 
Note: See TracChangeset for help on using the changeset viewer.