Jedi::Plugin::Template - Plugin for Template Toolkit


version 1.001


This is a Template::Toolkit plugin for Jedi web app framework.

Jedi is just a simple web app framework that help your create app above Plack.

This plugin handle your Template::Toolkit files for you.

It will use the Jedi config to get the directory of your templates. The default value is the dist_dir of your module.


The directory of your templates should look like :

 * public
 * views
   * layouts

The public directory contain all your static files. It is generally your javascripts and css.

The views directory contain all your template toolkit files.

The views/layouts contain all your template toolkit layout files.

To use it in your Jedi app :

  package MyApps;
  use Jedi::App;
  use Jedi::Plugin::Template;

  sub jedi_app {
    # ...
    $jedi->get('/bla', sub {
      my ($jedi, $request, $response) = @_;
        $jedi->jedi_template('', {hello => 'world'}, '');
      return 1;


The views directory here, look like :

 * views
   * layouts

The look like

  This will wrap your content :
  [% content %]

And your :

  <p>Hello [% hello %]</p>

CONFIGURATION: template_dir

By default Jedi::Plugin::Template will setup the 'template_dir' configuration to the dist_dir of your package :

  template_dir: DIST_DIR('MyApps')

You can create a config file to be able to do development in your working directory like this :

  template_dir: ./share/

In order to be able to deploy and use properly your app like any other perl packages, use the 'share' directory.

With Dist::Zilla it will be automatic if the "public" and "views" directory is placed under the "share" directory.

If you use Module::Build you need to defined :

 my %module_build_args = (
  # ...
  "share_dir" => {
   "dist" => "share"
  # ...

SET A DEFAULT LAYOUT: jedi_template_default_layout

 You can defined a default layout, by setting the attribute : 'jedi_template_default_layout'


GET YOUR TEMPLATE: jedi_template

The method 'jedi_template' will use Template to process your template.

  $jedi_app->jedi_template($file, \%vars);
  $jedi_app->jedi_template($file, \%vars, $layout);

The layout use the jedi_template_default_layout by default.

You can also remove any layout, using the value "none".

 $jedi_app->jedi_template($file, \%vars, 'none'),


The plugin will match all missing by sending a public file if this one exists. It handle cache and compression for you.

 * public
   * mystyle.css

 curl http://localhost:3000/mystyle.css

If no route match the '/mystyle.css', then the plugin will check in the public dir and send the file if this one is present.


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


celogeek <>


This software is copyright (c) 2013 by celogeek <>.

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