Newcomen

Description A static content generator.
Newcomen > Perl Modules > Newcomen::Renderer::TemplateToolkit
Source

Index


NAME ^

Newcomen::Renderer::TemplateToolkit - Template Toolkit renderer backend.

DESCRIPTION ^

Renderer backends are usually not called directly. See Newcomen::Renderer for the frontend documentation.

This module provides a renderer backend using Template Toolkit.

OPTIONS ^

{
   'renderer'           => {
      'templatetoolkit' => {
         'template'     => undef,
         'use_cache'    => 1,
      },
   },
}

These are the default options for this renderer backend. The user may override any default setting in the configuration file as required. However, plugins may decide to supersede the user defined options.

The renderer/templatetoolkit hashref may contain any Template Toolkit options as required, with the following addition: The options renderer/templatetoolkit/template and renderer/templatetoolkit/use_cache are not Template Toolkit options, but processed by this backend directly.

The template specifies the template file to be used for rendering. It will be passed to Template Toolkit's process() method. If it is not defined in the configuration it defaults to 'default.tt'.

The use_cache option indicates whether to cache the template objects or not. It defaults to 1, meaning caching is enabled, and may be set to any false value to disable it. Note that template objects will be cached based on the options set (these may differ for different pages, see the individual plugins that deal with these). Different options will cause different entries in the cache. Note that this is based on the actual contents of the options hashref, so - for example - including a default setting in one hashref and omitting it from another will cause two template objects to be created, even though their behaviour is exactly the same. Also note that this caching is different from Template Toolkit's own caching, which will save compiled templates on disk.

All other options will be used as configuration for Template Toolkit itself. Technically, the complete renderer/templatetoolkit hashref will be passed to Template Toolkit's constructor, after the template and use_cache keys have been deleted from it.

Note: At least the Template Toolkit option INCLUDE_PATH should be set, so the templates can be found. See Template Toolkit's documentation for details.

TEMPLATE VARIABLES ^

The following variables will be available in the template:

catalog

The main Newcomen::Catalog instance.

config (also available as c)

The main Newcomen::Config instance.

core

The main Newcomen::Core instance.

crawler

The main Newcomen::Crawler instance.

page (also available as p)

The Newcomen::Page instance that should be rendered.

plugins

The main Newcomen::Plugins instance.

site

The main Newcomen::Site instance.

url (also available as u)

The main Newcomen::URL instance.

CLASS AND INSTANCE METHODS ^

See Newcomen::Renderer::Backend.

MISCELLANEOUS ^

The render() method of this backend will die() if there is an error processing the template.

SEE ALSO ^

Template, Newcomen::Catalog, Newcomen::Config, Newcomen::Core, Newcomen::Crawler, Newcomen::Page, Newcomen::Plugins, Newcomen::Renderer, Newcomen::Renderer::Backend, Newcomen::Site, Newcomen::URL

VERSION ^

This is version 2014052501.

AUTHOR ^

Stefan Goebel - newcomen {at} subtype {dot} de

COPYRIGHT AND LICENSE ^

Copyright 2013-2014 Stefan Goebel.

This file is part of Newcomen.

Newcomen is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the license, or (at your option) any later version.

Newcomen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Newcomen. If not, see <http://www.gnu.org/licenses/>.