| Next: Yawns::Formatters::BBCode | Previous: Yawns::Date | [Table of Contents] |
Yawns::Formatters - A helper module for formatting user Text comments.
#!/usr/bin/perl -w
use Yawns::Formatters;
use strict;
# Get the list of available formatters.
my $factory = Yawns::Formatters->new;
my %installed = $factory->getAvailable();
# Create a new BBCode formatter.
my $bbcode = $factory->create( "bbcode", "text to be formated" );
This module allows the site to dynamically determine which formatting modules are available, and to create instances of each one.
It is a simple factory pattern, albeit a hard-wired one rather than a dynamic one.
Constructor, not really used for much.
Return the formatting types which are available.
Create an instance of the correct type - this is the factory part of the code.
Steve Kemp
http://www.steve.org.uk/
Copyright (c) 2007 by Steve Kemp. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.