Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Dancer::Template::HtmlTemplate - HTML::Template wrapper for Dancer
Perl
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Dancer/Template
t
Changes
MANIFEST
Makefile.PL
README
ignore.txt

README

NAME
    Dancer::Template::HtmlTemplate - HTML::Template wrapper for Dancer

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

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

        template: HtmlTemplate

    This can be done in your config.yml file or directly in your app code
    with the set keyword.

    Since HTML::Template uses different syntax to other template engines
    like Template::Toolkit, the default layout `main.tt' generated by the
    scaffolding script must be updated to use HTML::Template directives:

        [% content %]

    needs to be changed to:

        <!--tmpl_var name="content"-->

    or

        <TMPL_VAR name="content">

    Future versions of Dancer may ask you which template engine you wish to
    use, and write the default layout and example templates appropriately.

    Also, the current default file extension for template files is `.tt'; at
    the time this template engine wrapper was produced, the template engine
    wrapper could not override default file extensions. This is now
    possible, but I haven't made this change as it would break applications
    relying on the default being `.tt'.

    If you want to change the extension used, use the `extension'
    configuration option, for example, to declare that the extension should
    be `.tmpl':

        template: HtmlTemplate
        engines:
            HtmlTemplate:
                extension: 'tmpl'

    WARNING - Even if you use the default `.tt', you may want to explictly
    set the `extension' setting to indicate that, as future versions may
    default to a more suitable file extension.

Handling nested hashrefs
    Since HTML::Template does not allow you to access nested hashrefs (at
    least, not without switching to using HTML::Template::Pluggable along
    with HTML::Template::Plugin::Dot), this module "flattens" nested
    hashrefs.

    For instance, the session contents are passed to Dancer templates as
    `session' - to access a key of that hashref named `username', you'd say:

        <TMPL_VAR name="session.username">

SEE ALSO
    Dancer, HTML::Template

AUTHOR
    David Precious, `<davidp@preshweb.co.uk>'

CONTRIBUTING
    This module is developed on Github at:

    http://github.com/bigpresh/Dancer-Template-HtmlTemplate

    Feel free to fork the repo and submit pull requests!

ACKNOWLEDGEMENTS
    Thanks to Damien Krotkine for providing code to flatten nested hashrefs
    in a way that allows HTML::Template templates to make use of them.

LICENSE
    This module is free software and is released under the same terms as
    Perl itself.

Something went wrong with that request. Please try again.