GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOJOLICIOUS::PLUGIN::TTRENDERER (3)

.ds Aq ’

NAME

Mojolicious::Plugin::TtRenderer - Template Renderer Plugin for Mojolicious

CONTENTS

VERSION

version 1.57

SYNOPSIS

Mojolicious::Lite:



 plugin tt_renderer;



Mojolicious



 $self->plugin(tt_renderer);



DESCRIPTION

This plugin is a simple Template Toolkit renderer for Mojolicious. Its defaults are usually reasonable, although for finer grain detail in configuration you may want to use Mojolicious::Plugin::TtRenderer::Engine directly.

OPTIONS

These are the options that can be passed in as arguments to this plugin.

    template_options

Configuration hash passed into Template’s constructor, see Template Toolkit’s configuration summary for details. Here is an example using the Mojolicious::Lite form:



 plugin tt_renderer => {
   template_options => {
     PRE_CHOMP => 1,
     POST_CHOMP => 1,
     TRIM => 1,
   },
 };



Here is the same example using the full Mojolicious app form:



 package MyApp;

 use Mojo::Base qw( Mojolicious );

 sub startup {
   my($self) = @_;
  
   $self->plugin(tt_renderer => {
     template_options => {
       PRE_CHOMP => 1,
       POST_CHOMP => 1,
       TRIM => 1,
     },
   }
  
   ...
 }



These options will be used if you do not override them:
INCLUDE_PATH Generated based on your application’s renderer’s configuration. It will include all renderer paths, in addition to search files located in the __DATA__ section by the usual logic used by Mojolicious.
COMPILE_EXT .ttc
UNICODE 1 (true)
ENCODING utf-87
CACHE_SIZE 128
RELATIVE 1 (true)

    cache_dir

Specifies the directory in which compiled template files are written. This:



 plugin tt_renderer, { cache_dir => some/path };



is equivalent to



 plugin tt_renderer, { template_options { COMPILE_DIR => some/path } };



except in the first example relative paths are relative to the Mojolicious app’s home directory ($app->home).

STASH

    h

Helpers are available via the h entry in the stash.



 <a href="[% h.url_for(index) %]">go back to index</a>



    c

The current controller instance can be accessed as c.



 I see you are requesting a document from [% c.req.headers.host %].



EXAMPLES

Mojolicious::Lite example:



 use Mojolicious::Lite;

 plugin tt_renderer;

 get / => sub {
   my $self = shift;
   $self->render(index);
 };

 app->start;

 __DATA__

 @@ index.html.tt
 [%
    WRAPPER layouts/default.html.tt
    title = Welcome
 %]
 <p>Welcome to the Mojolicious real-time web framework!</p>
 <p>Welcome to the TtRenderer plugin!</p>
 [% END %]

 @@ layouts/default.html.tt
 <!DOCTYPE html>
 <html>
   <head><title>[% title %]</title></head>
   <body>[% content %]</body>
 </html>



Mojolicious example:



 package MyApp;
 use Mojo::Base Mojolicious;

 sub startup {
   my $self = shift;
   $self->plugin(tt_renderer);
   my $r = $self->routes;
   $r->get(/)->to(example#welcome);
 }

 1;

 package MyApp::Example;
 use Mojo::Base Mojolicious::Controller;

 # This action will render a template
 sub welcome {
   my $self = shift;

   # Render template "example/welcome.html.tt" with message
   $self->render(
     message => Looks like your TtRenderer is working!);
 }

 1;



These are also included with the Mojolicious::Plugin::TtRenderer distribution, including the support files required for the full Mojolicious app example.

SEE ALSO

Mojolicious::Plugin::TtRenderer::Engine, Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.

AUTHOR

Original author: Ask Bjo\k:/rn Hansen

Current maintainer: Graham Ollis <plicease@cpan.org>

Contributors:

vti

Marcus Ramberg

Matthias Bethke

Htbaa

Magnus Holm

Maxim Vuets

Rafael Kitover

giftnuss

Cosimo Streppone

Fayland Lam

Jason Crowther

spleenjack

A\k:'|\n:ud Sza\k:'\h |\n:usz

XXXXXX XXXXXXX

uwisser

Dinis Lage

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Ask Bjo\k:/rn Hansen.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOJOLICIOUS::PLUGIN::TTRENDERER (3) 2016-04-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.