Dancer-Template-TemplateFlute

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Dancer::Template::TemplateFlute - Template::Flute wrapper for Dancer

VERSION
    Version 0.0142

DESCRIPTION
    This class is an interface between Dancer'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:

        <specification>
        <value name="content" id="content" op="hook"/>
        </specification>

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

        <div id="content">
        Your content
        </div>

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

      engines:
        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_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> is different from `request-'path_info>.

  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.

    By default, the class `Dancer::Session::Abstract' is treated this way.
    You can specify additional classes with the following syntax:

      engines:
        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_flute:
          i18n:
            class: MyApp::Lexicon
            method: try_to_translate

    A class could be something like this:

      package MyTestApp::Lexicon;
      use Dancer ':syntax';

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



( run in 1.357 second using v1.01-cache-2.11-cpan-71847e10f99 )