NAME

Prancer::Plugin::Xslate

SYNOPSIS

This plugin provides access to the Text::Xslate templating engine for your Prancer application and exports a keyword to access the configured engine.

This template plugin supports setting the basic configuration in your Prancer application's configuration file. You can also configure all options at runtime using arguments to render.

To set a configuration in your application's configuration file, begin the configuration block with template and put all options underneath that. For example:

template:
    cache_dir: /path/to/cache
    verbose: 2

Any option for Text::Xslate whose value can be expressed in a configuration file can be put into your application's configuration. Then using the template engine is as simple as this:

use Prancer::Plugin::Xslate qw(render);

my $plugin = Prancer::Plugin::Xslate->load();
$plugin->add_module("Data::Dumper");

print render("foobar.tx", \%vars);

However, there are some configuration options that cannot be expressed in configuration files, especially the functions option. So there is a second way to handle that.

print render("foobar.tx", \%vars, {
    'function' => {
        'md5_hex' => sub {
            return Digest::MD5::md5_hex(@_);
        }
    }
});

The optional third argument to render can be a hashref with additional, overriding options for Text::Xslate.

METHODS

COPYRIGHT

Copyright 2014 Paul Lockaby. All rights reserved.

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

SEE ALSO