NAME Mojolicious::Plugin::PetalTinyRenderer - Petal::Tiny renderer plugin SYNOPSIS # Mojolicious $self->plugin('PetalTinyRenderer'); # Mojolicious::Lite plugin 'PetalTinyRenderer'; DESCRIPTION Mojolicious::Plugin::PetalTinyRenderer is a renderer for templates written for Petal::Tiny, which is a Perl implementation of the Template Attribute Language (TAL). OPTIONS Mojolicious::Plugin::PetalTinyRenderer supports the following option. name # Mojolicious::Lite plugin PetalTinyRenderer => {name => 'petal'}; Handler name, defaults to tal. encoding Encoding of the template-files as supplied to open, defaults to :encoding(UTF-8). STASH The stash is directly available in the templates, see the use of foo in the example. h Helpers are available via the h entry in the stash. go back to index c The current controller instance can be accessed as c. I see you are requesting a document from Lorem ipsum. USEFUL PATTERNS Call helper-function without generating html (-- prefixes a literal string): Use a temporary variable to hold dynamically generated string for helper function: Insert styled paragraph with error-message, if any (the structure keyword means don't escape returned html):
Error message
Include other action/template: You can loop over Mojo::Collections: See Petal::Tiny for more. Author's observation: If you need to write very complex TAL-constructs, maybe you should reconsider what belongs in the controller and what belongs in the template. TAL seems to be very good at exposing this anti-pattern. EXAMPLE use Mojolicious::Lite; plugin 'PetalTinyRenderer'; get '/' => sub { my $self = shift; $self->stash( foo => Mojo::Collection->new(1,2,3) ); $self->render('index'); }; app->start; __DATA__ @@ layouts/default.html.tal: Welcome to the PetalTinyRenderer plugin!
SEE ALSO Petal::Tiny, Mojolicious, Mojolicious::Guides, http://mojolicio.us. AUTHOR Lars Balker