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 Lorem Ipsum @@ index.html.tal

    : Welcome to the PetalTinyRenderer plugin!

    SEE ALSO Petal::Tiny, Mojolicious, Mojolicious::Guides, AUTHOR Lars Balker COPYRIGHT AND LICENSE This software is copyright (c) 2014 by DK Hostmaster A/S. This is free software, licensed under: The MIT (X11) License The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.