View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Zoffix Znet > App-ZofCMS-1.001006 > App::ZofCMS::Plugin::FileToTemplate



Annotate this POD


View/Report Bugs
Module Version: 1.001006   Source   Latest Release: App-ZofCMS-1.001007


App::ZofCMS::Plugin::FileToTemplate - read or do() files into ZofCMS Templates


In your ZofCMS Template:

    plugins => [ qw/FileToTemplate/ ],
    t  => {
        foo => '<FTTR:index.tmpl>',

In you HTML::Template template:

    <tmpl_var escape='html' name='foo'>


The module is a plugin for App::ZofCMS; it provides functionality to either read (slurp) or do() files and stick them in place of "tags".. read on to understand more.

This documentation assumes you've read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template


    plugins => [ qw/FileToTemplate/ ],

Unlike many other plugins to run this plugin you barely need to include it in the list of plugins to execute.


    t  => {
        foo => '<FTTR:index.tmpl>',
        bar => '<FTTD:index.tmpl>',

Anywhere in your ZofCMS template you can use two "tags" that this plugin provides. Those "tags" will be replaced - depending on the type of tag - with either the contents of the file or the last value returned by the file.

Both tags are in format: opening angle bracket, name of the tag in capital letters, semicolon, filename, closing angle bracket. The filename is relative to your "templates" directory, i.e. the directory referenced by templates key in Main Config file.


    t  => {
        foo => '<FTTR:index.tmpl>',

The <FTTR:filename> reads (slurps) the contents of the file and tag is replaced with those contents. You can have several of these tags as values. Be careful reading in large files with this tag. Mnemonic: File To Template Read.


    t => {
        foo => '<FTTD:index.tmpl>',

The <FTTD:filename> tag will do() your file and the last returned value will be assigned to the value in which the tag appears, in other words, having foo => '<FTTD:index.tmpl>', and foo => '<FTTD:index.tmpl> blah blah blah', is the same. Using this tag, for example, you can add large hashrefs or config hashrefs into your templates without clobbering them. Note that if the do() cannot find your file or compilation of the file fails, the value with the tag will be replaced by the error message. Mnemomic: File To Template Do.


The plugin requires one non-core module: Data::Transformer


Fork this module on GitHub:


To report bugs or request features, please use

If you can't access GitHub, you can email your request to bug-App-ZofCMS at


Zoffix Znet <zoffix at> (,


You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.

syntax highlighting: