[%# Template for handling all manner of statements in TentMaker templates. Expects these parameters: method_group - the star in update_*_bool name_prefix - beginning of input element name, this must correspond to the TentMaker.pm update_* method. Used only for multiples and pairs. id_prefix - beginning of the input element id the AST ident should be part of this keyword_prefix - Used in front of the keyword when forming names and the callback parameter. Include your own trailing double colon. single_value - initial value (singular) for all types ignored if statement.multiple is set values - initial values (plural) for text type when multiple is set key - the keyword of this statement (same as statement.keyword below) statement - hash of legal statements whose keys are below keys in the statement hash: type - pick from: text, textarea, select, boolean, pair, or controlled_boolean keyword - statement's keyword default - what to use if boolean (or controlled_boolean) value is undefined multiple - indicates that more than one value or pair can be given for the keyword (think comma separated list). Only applies to types text, select, and pair. pair_labels - Headings to put over pair entry text boxes. Only applies to type pair. false - the text of the false value for controlled_boolean if no value is given, 'undef' is used true - similar to false, guess how they differ options - an array of hashes required for type selectone each hash has two keys: value and label urgency - fills in the * in class='urgency_*' this is used for color coding important fields choose from 0, 1, 3, 5, or 10 which are (roughly) white, lt. blue, green, orange, or red values are double qouted to prevent clashes with single quotes in the values -%] [%- full_key = "$keyword_prefix$key"; full_name = "$name_prefix$key"; full_id = "$id_prefix$key"; -%] [% IF statement.type == 'textarea' %] [% ELSIF statement.type == 'boolean' %] [% ELSIF statement.type == 'controlled_boolean' %] [% ELSIF statement.type == 'text' %] [% IF statement.multiple %] [% FOREACH element IN values %]
[% END %] [% FOREACH extra_input IN [ 1..2 ] %] [% UNLESS loop.last %]
[% END %] [% END %] [% ELSE %] [% END %] [% ELSIF statement.type == 'select' %] [% ELSIF statement.type == 'pair' %] [% FOREACH existing_value IN values %] [% choice_parts = existing_value.split(' => ') %] [% pair_urgency = statement.urgency || 0 %] [% UNLESS statement.pair_required %] [% pair_urgency = 0 %] [% END %] [% END %] [% IF statement.multiple OR values.length == 0 %] [%- pair_urgency = statement.urgency || 0 -%] [%- UNLESS statement.pair_required; pair_urgency = 0; END -%] [% END %]
[% statement.pair_labels.0 %] [% statement.pair_labels.1 %] [% UNLESS statement.pair_required %] [optional] [% END %]
[% quote_type = ( choice_parts.1.match( '"' ) ) ? "'" : '"' %]
[% ELSE %] I don't know what to do with:
[% USE dumper %][% dumper.dump( statement ) %]
[% END %]