NAME

Template::Flute::Specification - Specification class for Template::Flute

SYNOPSIS

    $xml_spec = new Template::Flute::Specification::XML;
    $spec = $xml_spec->parse_file('spec.xml');
    $spec->set_iterator('cart', $cart);

    $conf_spec = new Template::Flute::Specification::Scoped;
    $spec = $conf_spec->parse_file('spec.conf);

DESCRIPTION

Specification class for Template::Flute.

CONSTRUCTOR

new

Creates Template::Flute::Specification object.

METHODS

name NAME

Set or get the name of the specification.

encoding ENCODING

Set or get the encoding of the HTML template which is parsed according to this specification.

container_add CONTAINER

Add container specified by hash reference CONTAINER.

list_add LIST

Add list specified by hash reference LIST.

paging_add PAGING

form_add FORM

Add form specified by hash reference FORM.

value_add VALUE

Add value specified by hash reference VALUE.

i18n_add I18N

Add i18n specified by hash reference I18N.

pattern_add({ name => 'pxt', regexp => qr/\Qmy string\E/ });

Add a pattern to the specification. The two keys name and regexp are mandatory.

patterns

Returns a plain hash with name => regexp pairs of the patterns set in the specification.

list_iterator NAME

Returns iterator for list named NAME or undef.

list_inputs NAME

Returns inputs for list named NAME or undef.

list_sorts NAME

Return sorts for list named NAME or undef.

list_filters NAME

Return filters for list named NAME or undef.

form_inputs NAME

Return inputs for form named NAME or undef.

iterator NAME

Returns iterator identified by NAME.

set_iterator NAME ITER

Sets iterator for NAME to ITER. ITER can be a iterator object like Template::Flute::Iterator or a reference to an array containing hash references.

resolve_iterator INPUT

Resolves iterator INPUT.

elements_by_class NAME

Returns element(s) of the specification tied to HTML class NAME or undef.

elements_by_name NAME

Returns element(s) of the specification tied to HTML attribute name or undef.

elements_by_id NAME

Returns element(s) of the specification tied to HTML id NAME or undef.

list_paging NAME

Returns paging for list NAME.

dangling

Method to check if the template is consistent with the specification. The method retrieves the list of ids, classes and names, and check if there are template elements attached.

For each specification element without template elements attached, it produces a hash reference with the name, type and a dump of the element.

It returns a list of these hash references, so you can check the template with

    my $flute = Template::Flute->new(....);
    my @bad_elts = $flute->specification->dangling;

    if (@bad_elts) {
        warn "empty elements" . Dumper(\@bad_elts);
    }
    else {
        print "all ok\n";
    }

Each hashref returned has the following keys set:

name
type
dump

Beware that to call this method successfully, the specification must already be processed, so it's safer to call it after $flute->process.

AUTHOR

Stefan Hornburg (Racke), <racke at linuxia.de>

BUGS

Please report any bugs or feature requests at https://github.com/racke/Template-Flute/issues.

LICENSE AND COPYRIGHT

Copyright 2010-2021 Stefan Hornburg (Racke) <racke@linuxia.de>.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.