NAME

Yukki::TemplateUtil - Utiltiies that help make manipulating the DOM easier

VERSION

version 0.991_004

DESCRIPTION

Tools for manipulating the DOM in specialized wasy inside of Template::Pure templates.

SUBROUTINES

field

    $view->prepare_template(
        template => 'admin/user/edit.html',
        directives => [
            ...
            '#email@value' => field(['user.email', 'form.email']),
            ...
        ],
    );

Template::Pure is touchy about missing paths. This will make sure a field is present so the template renders okay without requiring any additional boilerplate. First argument is the name of the data path or paths to lookup. Multiple paths may be passed using an array reference. The second value (optional) is the default to use if that finds nothing. If no default is given, the default default is an empty string.

form_error

    $view->prepare_template(
        template => 'admin/user/edit.html',
        directives => [
            ...
            '#email' => form_error('email'),
            ...
        ],
    );

Appends content after an element to insert code to show field errors, if field errors are set.

mark_radio_checked

    $view->prepare_template(
        template => ...,
        directives => [
            ...,
            '#anonymous_access_level' => mark_radio_checked(
                'anonymous_access_level',
                'repository.anonymous_access_level',
                'form.anonymous_access_level',
            ),
        ],
    );

Returns a subroutine that will set a radio button to the given value.

    my @directives = mark_radio_checked($field_name, @data_paths);

The $field_name gives the the name attribute of the radios to try. The returned sub checks each @data_path sequentially and ignores missing paths.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Qubling Software LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.