README
1NAME
2 HTML::Template::Pluggable - Extends HTML::Template with plugin support
3
4SYNOPSIS
5 Just use this module instead of HTML::Template, then use any plugins,
6 and go on with life.
7
8 use HTML::Template::Pluggable;
9 use HTML::Template::Plugin::Dot;
10
11 # Everything works the same, except for functionality that plugins add.
12 my $t = HTML::Template::Pluggable->new();
13
14THE GOAL
15 Ideally we'd like to see this functionality merged into HTML::Template,
16 and turn this into a null sub-class.
17
18STATUS
19 The design of the plugin system is still in progress. Right now we have
20 just two triggers, in param and output. The name and function of this
21 may change, and we would like to add triggers in new() and other methods
22 when the need arises.
23
24 All we promise for now is to keep HTML::Template::Plugin::Dot
25 compatible. Please get in touch if you have suggestions with feedback on
26 designing the plugin system if you would like to contribute.
27
28WRITING PLUGINS
29 HTML::Template offers a plugin system which allows developers to extend
30 the functionality in significant ways without creating a creating a
31 sub-class, which might be impossible to use in combination with another
32 sub-class extension.
33
34 Currently, two triggers have been made available to alter how the values
35 of TMPL_VARs are set. If more hooks are needed to implement your own
36 plugin idea, it may be feasible to add them-- check the FAQ then ask
37 about it on the list.
38
39 Class::Trigger is used to provide plugins. Basically, you can just:
40
41 HTML::Template->add_trigger('middle_param', \&trigger);
42
43 A good place to add one is in your plugin's "import" subroutine:
44
45 package HTML::Template::Plugin::MyPlugin;
46 use base 'Exporter';
47 sub import {
48 HTML::Template->add_trigger('middle_param', \&dot_notation);
49 goto &Exporter::import;
50 }
51
52 TRIGGER LOCATIONS
53 param
54 We have added one trigger location to this method, named
55 "middle_param".
56
57 # in a Plugin's import() routine.
58 HTML::Template->add_trigger('middle_param', \&_set_tmpl_var_with_dot );
59
60 This sets a callback which is executed in param() with all of the
61 same arguments. It is only useful for altering how /setting/ params
62 works. The logic to read a param is unaffected.
63
64 It can set any TMPL_VAR values before the normal param logic kicks
65 in. To do this, "$self->{param_map}" is modified as can be seen from
66 source in HTML::Template::param(). However, it must obey the
67 following convention of setting $self->{param_map_done}{$param_name}
68 for each param that is set. $param_name would be a key from
69 "$self->{param_map}". This notifies the other plugins and the core
70 param() routine to skip trying to set this value.
71 $self->{param_map_done} is reset with each call to param(), so that
72 like with a hash, you have the option to reset a param later with
73 the same name.
74
75 output
76 One trigger location here: "before_output".
77
78 HTML::Template->add_trigger('before_output', \&_last_chance_params );
79
80 This sets a callback which is executed right before output is
81 generated.
82
83SEE ALSO
84 o HTML::Template::Plugin::Dot - Add Template Toolkit's magic dot
85 notation to HTML::Template.
86
87AUTHOR
88 Mark Stosberg, "<mark@summersault.com>"
89
90BUGS
91 Please report any bugs or feature requests to
92 "bug-html-template-pluggable@rt.cpan.org", or through the web interface
93 at <http://rt.cpan.org>. I will be notified, and then you'll
94 automatically be notified of progress on your bug as I make changes.
95
96Copyright & License
97 Copyright 2006 Mark Stosberg, All Rights Reserved.
98
99 This program is free software; you can redistribute it and/or modify it
100 under the same terms as Perl itself.
101
102