NAME

Template::Provider::CustomDBIC - Load templates using DBIx::Class

SYNOPSIS

use My::CustomDBIC::Schema;
use Template;
use Template::Provider::CustomDBIC;

my $schema = My::CustomDBIC::Schema->connect(
    $dsn, $user, $password, \%options
);
my $resultset = $schema->resultset('Template');

If all of your templates are stored in a single table the most convenient method is to pass the provider a DBIx::Class::ResultSet.

my $template = Template->new({
    LOAD_TEMPLATES => [
        Template::Provider::CustomDBIC->new({
            RESULTSET => $resultset,
            # Other template options like COMPILE_EXT...
        }),
    ],
});

# Process the template in 'column' referred by reference from resultset 'Template'.
$template->process('table/reference/column');

DESCRIPTION

Template::Provider::CustomDBIC allows a Template object to fetch its data using DBIx::Class instead of, or in addition to, the default filesystem-based Template::Provider.

SCHEMA

This provider requires a schema containing at least the following:

OPTIONS

In addition to supplying a RESULTSET or SCHEMA and the standard Template::Provider options, you may set the following preferences:

METHODS

->fetch( $name )

This method is called automatically during Template's ->process() and returns a compiled template for the given $name, using the cache where possible.

USE WITH OTHER PROVIDERS

By default Template::Provider::CustomDBIC will raise an exception when it cannot find the named template

my $template = Template->new({
    LOAD_TEMPLATES => [
        Template::Provider::CustomDBIC->new({
            RESULTSET => $resultset,
        }),
        Template::Provider->new({
            INCLUDE_PATH => $path_to_templates,
        }),
    ],
});

CACHING

When caching is enabled, by setting COMPILE_DIR and/or COMPILE_EXT, Template::Provider::CustomDBIC will create a directory consisting of the database DSN and table name. This should prevent conflicts with other databases and providers.

SEE ALSO

Template, Template::Provider, DBIx::Class::Schema

DIAGNOSTICS

In addition to errors raised by Template::Provider and DBIx::Class, Template::Provider::CustomDBIC may generate the following error messages:

DEPENDENCIES

Additionally, use of this module requires an object of the class DBIx::Class::Schema or DBIx::Class::ResultSet.

BUGS

Please report any bugs or feature requests through the web interface at https://github.com/itnode/Template-Provider-CustomDBIC/issues

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Template::Provider::CustomDBIC

You may also look for information at:

AUTHOR

Jens Gassmann jegade@cpan.org

Based on work from Dave Cardwell dcardwell@cpan.org

COPYRIGHT AND LICENSE

Copyright (c) 2015 Jens Gassmann. All rights reserved.

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