<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Dancer2::Template::TemplateFlute - Template::Flute wrapper for Dancer2

VERSION
    Version 0.202

DESCRIPTION
    This class is an interface between Dancer2's template engine abstraction
    layer and the Template::Flute module.

    In order to use this engine, use the template setting:

        template: template_flute

    The default template extension is ".html".

  LAYOUT
    Each layout needs a specification file and a template file. To embed the
    content of your current view into the layout, put the following into
    your specification file, e.g. views/layouts/main.xml:

        &lt;specification&gt;
        &lt;value name="content" id="content" op="hook"/&gt;
        &lt;/specification&gt;

    This replaces the contents of the following block in your HTML template,
    e.g. views/layouts/main.html:

        &lt;div id="content"&gt;
        Your content
        &lt;/div&gt;

  ITERATORS
    Iterators can be specified explicitly in the configuration file as
    below.

      engines:
        template:
          template_flute:
            iterators:
              fruits:
                class: JSON
                file: fruits.json

  FILTER OPTIONS
    Filter options and classes can be specified in the configuration file as
    below.

      engines:
        template:
          template_flute:
            filters:
              currency:
                options:
                  int_curr_symbol: "$"
              image:
                class: "Flowers::Filters::Image"

  ADJUSTING URIS
    We automatically adjust links in the templates if the value of
    "request-"path&gt; is different from "request-"path_info&gt;.

  EMBEDDING IMAGES IN EMAILS
    If you pass a value named "email_cids", which should be an empty hash
    reference, all the images "src" attributes will be rewritten using the
    CIDs, and the reference will be populated with an hashref, as documented
    in Template::Flute

    Further options for the CIDs should be passed in an optional value named
    "cids". See Template::Flute for them.

  DISABLE OBJECT AUTODETECTION
    Sometimes you want to pass values to a template which are objects, but
    don't have an accessor, so they should be treated like hashrefs instead.

    You can specify classes with the following syntax:

      engines:
        template:
          template_flute:
            autodetect:
              disable:
                - My::Class1
                - My::Class2

    The class matching is checked by Template::Flute with "isa", so any
    parent class would do.

  LOCALIZATION
    Templates can be localized using the Template::Flute::I18N module. You
    can define a class that provides a method which takes as first (and only
    argument) the string to translate, and returns the translated one. You
    have to provide the class and the method. If the class is not provided,
    no localization is done. If no method is specified, 'localize' will be
    used. The app will crash if the class doesn't provide such method.

    Be sure to return the argument verbatim if the module is not able to
    translate the string.

    Example configuration, assuming the class "MyApp::Lexicon" provides a
    "try_to_translate" method.

      engines:
        template:
          template_flute:
            i18n:
              class: MyApp::Lexicon
              method: try_to_translate

    A class could be something like this:

      package MyTestApp::Lexicon;
      use Dancer2;

      sub new {
          my $class = shift;
          debug "Loading up $class";
          my $self = {
                      dictionary =&gt; {
                                     en =&gt; {
                                            'TRY' =&gt; 'Try',
                                           },
                                     it =&gt; {
                                            'TRY' =&gt; 'Prova',
                                           },
                                    }
                     };
          bless $self, $class;
      }

      sub dictionary {
          return shift-&gt;{dictionary};
      }

      sub try_to_translate {
          my ($self, $string) = @_;
          my $lang = session('lang') || var('lang');
          return $string unless $lang;
          return $string unless $self-&gt;dictionary-&gt;{$lang};
          my $tr = $self-&gt;dictionary-&gt;{$lang}-&gt;{$string};
          defined $tr ? return $tr : return $string;
      }

      1;

    Optionally, you can pass the options to instantiate the class in the
    configuration. Like this:

      engines:
        template:
          template_flute:
            i18n:
              class: MyApp::Lexicon
              method: localize
              options:
                append: 'X'
                prepend: 'Y'
                lexicon: 'path/to/po/files'

    This will call

     MyApp::Lexicon-&gt;new(append =&gt; 'X', prepend =&gt; 'Y', lexicon =&gt; 'path/to/po/files');

    when the engine is initialized, and will call the "localize" method on
    it to get the translations.

  DEBUG TOOLS
    If you set "check_dangling" in the engine stanza, the specification will
    run a check (using the Template::Flute::Specification's "dangling"
    method) against the template to see if you have elements of the
    specifications which are not bound to any HTML elements.

    In this case a debug message is issued (so keep in mind that with higher
    logging level you are not going to see it).

    Example configuration:

      engines:
        template:
          template_flute:
            check_dangling: 1

    When the environment is set to "development" this feature is turned on
    by default. You can silence the logs by setting:

      engines:
        template:
          template_flute:
            disable_check_dangling: 1

  FORMS
    Dancers::Template::TemplateFlute has a form plugin
    Dancer2::Plugin::TemplateFlute which must be installed in order to use
    Template::Flute forms.

    The token "form" is reserved for forms. It can be a single
    Dancer2::Plugin::TemplateFlute form object or an arrayref of
    Dancer2::Plugin::TemplateFlute form objects.

   Typical usage for a single form.
   XML Specification
      &lt;specification&gt;
      &lt;form name="registration" link="name"&gt;
      &lt;field name="email"/&gt;
      &lt;field name="password"/&gt;
      &lt;field name="verify"/&gt;
      &lt;/form&gt;
      &lt;/specification&gt;

   HTML
      &lt;form class="frm-default" name="registration" action="/register" method="POST"&gt;
            &lt;fieldset&gt;
              &lt;div class="reg-info"&gt;Info&lt;/div&gt;
              &lt;ul&gt;
                    &lt;li&gt;
                      &lt;label&gt;Email&lt;/label&gt;
                      &lt;input type="text" name="email"/&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;label&gt;Password&lt;/label&gt;
                      &lt;input type="text" name="password"/&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;label&gt;Confirm password&lt;/label&gt;
                      &lt;input type="text" name="verify" /&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;input type="submit" value="Register" class="btn-submit" /&gt;
                    &lt;/li&gt;
              &lt;/ul&gt;
            &lt;/fieldset&gt;
      &lt;/form&gt;

   Code
      any [qw/get post/] =&gt; '/register' =&gt; sub {
          my $form = request-&gt;is_post
              ? form('registration', source =&gt; 'body')
              : form('registration', source =&gt; 'session' );
          my %values = %{$form-&gt;values};
          # VALIDATE, filter, etc. the values
          template register =&gt; {form =&gt; $form };
      };

   Usage example for multiple forms
   Specification
      &lt;specification&gt;
      &lt;form name="registrationtest" link="name"&gt;
      &lt;field name="emailtest"/&gt;
      &lt;field name="passwordtest"/&gt;
      &lt;field name="verifytest"/&gt;
      &lt;/form&gt;
      &lt;form name="logintest" link="name"&gt;
      &lt;field name="emailtest_2"/&gt;
      &lt;field name="passwordtest_2"/&gt;
      &lt;/form&gt;
      &lt;/specification&gt;

   HTML
      &lt;h1&gt;Register&lt;/h1&gt;
      &lt;form class="frm-default" name="registrationtest" action="/multiple" method="POST"&gt;
            &lt;fieldset&gt;
              &lt;div class="reg-info"&gt;Info&lt;/div&gt;
              &lt;ul&gt;
                    &lt;li&gt;
                      &lt;label&gt;Email&lt;/label&gt;
                      &lt;input type="text" name="emailtest"/&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;label&gt;Password&lt;/label&gt;
                      &lt;input type="text" name="passwordtest"/&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;label&gt;Confirm password&lt;/label&gt;
                      &lt;input type="text" name="verifytest" /&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;input type="submit" name="register" value="Register" class="btn-submit" /&gt;
                    &lt;/li&gt;
              &lt;/ul&gt;
            &lt;/fieldset&gt;
      &lt;/form&gt;
      &lt;h1&gt;Login&lt;/h1&gt;
      &lt;form class="frm-default" name="logintest" action="/multiple" method="POST"&gt;
            &lt;fieldset&gt;
              &lt;div class="reg-info"&gt;Info&lt;/div&gt;
              &lt;ul&gt;
                    &lt;li&gt;
                      &lt;label&gt;Email&lt;/label&gt;
                      &lt;input type="text" name="emailtest_2"/&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;label&gt;Password&lt;/label&gt;
                      &lt;input type="text" name="passwordtest_2"/&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                      &lt;input type="submit" name="login" value="Login" class="btn-submit" /&gt;
                    &lt;/li&gt;
              &lt;/ul&gt;
            &lt;/fieldset&gt;
      &lt;/form&gt;

   Code
      any [qw/get post/] =&gt; '/multiple' =&gt; sub {
          my ( $login_form, $registration_form );
          debug to_dumper({params});

          if (params-&gt;{login}) {
              $login_form = form('logintest', source =&gt; 'parameters');
              my %vals = %{$login-&gt;values};
              # VALIDATE %vals here
          }
          else {
              # pick from session
              $login_form = form('logintest', source =&gt; 'session');
          }

          if (params-&gt;{register}) {
              $registration_form = form('registrationtest', source =&gt; 'parameters');
              my %vals = %{$registration-&gt;values};
              # VALIDATE %vals here
          }
          else {
              # pick from session
              $registration_form = form('registrationtest', source =&gt; 'session');
          }
          template multiple =&gt; { form =&gt; [ $login_form, $registration_form ] };
      };

METHODS
  default_tmpl_ext
    Returns default template extension.

  render TEMPLATE TOKENS
    Renders template TEMPLATE with values from TOKENS.

SEE ALSO
    Dancer2, Template::Flute

AUTHOR
    Author of the original Dancer module:

    Stefan Hornburg (Racke), "&lt;racke at linuxia.de&gt;"

    Conversion to Dancer2:

    Peter Mottram (SysPete), "&lt;peter@sysnix.com&gt;"

    Author of the original version of this Dancer2 module:

    William Carr (mrmaloof), "&lt;bill at bottlenose-wine.com&gt;"

BUGS
    Please report any bugs or feature requests via the GitHub issue tracker
    at:
    &lt;https://github.com/interchange/Dancer2-Template-TemplateFlute/issues&gt;

SUPPORT
    You can find documentation for this module with the perldoc command.

        perldoc Dancer2::Template::TemplateFlute

    You can also look for information at:

    *   AnnoCPAN: Annotated CPAN documentation

        &lt;http://annocpan.org/dist/Dancer2-Template-TemplateFlute&gt;

    *   CPAN Ratings

        &lt;http://cpanratings.perl.org/d/Dancer2-Template-TemplateFlute&gt;

    *   meta::cpan

        &lt;https://metacpan.org/pod/Dancer2::Template::TemplateFlute&gt;

LICENSE AND COPYRIGHT
    Copyright 2011-2016 Stefan Hornburg (Racke) &lt;racke@linuxia.de&gt;.

    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.

</pre></body></html>