NAME

Templer::Plugin::FileGlob - A plugin to expand file globs.

SYNOPSIS

The following is a good example use of this plugin

title: Images of cats
images: file_glob( img/candid*.jpg )
----
<li>
<!-- tmpl_loop name='images' -->
  <li><img src="<!-- tmpl_var name='file' -->" width="<!-- tmpl_var name='width' -->" height="<!-- tmpl_var name='height' -->"  alt="Animal &amp; Pet Photography, Edinburgh" /></li>
<!-- /tmpl_loop -->
</ul>

DESCRIPTION

This plugin operates on file-patterns and populates loops refering to the specified pattern.

The intended use-case is inline-gallery generation, but more uses would surely be discovered.

For each loop created there will be the variables:

file

The name of the file.

height

The height of the image, if the file is an image and Image::Size is available.

width

The width of the image, if the file is an image and Image::Size is available.

content

The content of the file if the file is not an image and not a templer input file.

dirname

The directory part of the file name.

basename

The basename of the file (without extension).

extension

The extension (everything after the last period) of the file name.

If matching files are templer input files then all templer variables are also populated.

LICENSE

This module is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version, or

b) the Perl "Artistic License".

AUTHOR

Steve Kemp <steve@steve.org.uk>

COPYRIGHT AND LICENSE

Copyright (C) 2012-2014 Steve Kemp <steve@steve.org.uk>.

This library is free software. You can modify and or distribute it under the same terms as Perl itself.

METHODS

Constructor. No arguments are required/supported.

expand_variables

This is the method which is called by the Templer::Plugin::Factory to expand the variables contained in a Templer::Site::Page object.

Variables are written in the file in the form "key: value", and are internally stored within the Page object as a hash.

This method iterates over each key & value and updates any that seem to refer to file-globs.