Dancer::Template::Handlebars::Helpers - parent class for Handlebars' helper collections
version 0.2.2
package MyApp::HandlebarsHelpers; use parent Dancer::Template::Handlebars::Helpers; sub shout :Helper { my( $context, $text ) = @_; return uc $text; } sub internal_name :Helper(whisper) { my( $context, $text ) = @_; return lc $text; } 1;
and then in the Dancer app config.yml:
engines: handlebars: helpers: - MyApp::HandlebarsHelpers
Base class for modules containing Handlebars helper functions. The helper functions are labelled with the :Helper attribute. A name for the helper function can be passed or, if not, will default to the sub's name.
:Helper
Behind the curtain, what the attribute does is to add the tagged functions to a module-wide %HANDLEBARS_HELPERS variable, which has the function names as keys and their coderefs as values. For example, to register the functions of the SYNOPSIS without the help of Dancer::Template::Handlebars::Helpers, one could do:
%HANDLEBARS_HELPERS
Dancer::Template::Handlebars::Helpers
package MyApp::HandlebarsHelpers; our HANDLEBARS_HELPERS = ( shout => \&shout, whisper => \&internal_name, ); sub shout { my( $context, $text ) = @_; return uc $text; } sub internal_name { my( $context, $text ) = @_; return lc $text; } 1;
Yanick Champoux <yanick@babyl.dyndns.org>
This software is copyright (c) 2014 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Dancer::Template::Handlebars, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Template::Handlebars
CPAN shell
perl -MCPAN -e shell install Dancer::Template::Handlebars
For more information on module installation, please visit the detailed CPAN module installation guide.