NAME

Templer::Plugin::Factory - A simple plugin class

DESCRIPTION

This class implements a singleton within which plugin classes may be registered and retrieved.

The plugins used by templer are of two forms:

formatters

These plugins operate upon the text contained in Templer::Site::Page objects and transform the input into HTML.

variable expanders

These plugins, also operating on Templer::Site::Page objects, are allowed the opportunity to modify, update, replace, or delete the various per-page variables.

Plugins of each type register themselves by calling the appropriate methods in this class.

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-2015 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

new

Constructor.

This class is a singleton, so this method will either construct an instance of this class or return the global instance.

load_plugins

This method loads "*.pm" from the given directory.

register_formatter

This method should be called by all formatting plugins to register themselves. The two arguments are the name of the input-format, and the class-name which may be instantiated to process that kind of input.

Templer::Plugin::Textile and Templer::Plugin::Markdown are example classes.

register_filter

This method should be called by all template filter plugins to register themselves. The two arguments are the name of the template-filter, and the class-name which may be instantiated to process that kind of input.

Templer::Plugin::Dollar and Templer::Plugin::Strict are example classes.

register_plugin

This method should be called by all variable-expanding plugins to register themselves. The expected argument is the class-name which may be instantiated to expand variables.

Templer::Plugin::ShellCommand, Templer::Plugin::FileGlob, and Templer::Plugin::FileContents are examples of such plugins.

NOTE: The plugin is instantiated immediately, and kept alive for the duration of a templer-run.

expand_variables

Expand variables via all loaded plugins.

cleanup

For each loaded plugin invoke the "cleanup" method, if it exists.

This can be useful if you wish a plugin to generate a site-map, or similar.

formatter

Return a new instance of the formatter class with the given name.

undef is returned if no such plugin is registered.

formatters

Return the names of each registered formatter-plugin, this is only used by the test-suite.

filter

Return a new instance of the filter class with the given name.

undef is returned if no such plugin is registered.

filters

Return the names of each registered filter-plugin, this is only used by the test-suite.