I've made a new developer release of AnyTemplate with the following
features:
* use C::A hook system for pre/post processing
* now compatible with the native C::A load_tmpl hook
* can now emulate $self->load_tmpl
* automatic template names now come from $self->get_current_runmode,
not the name of the calling sub
* new 'forward' method to change current runmode
* associate_query and emulate_associate query now off by default
and the feature is now deprecated
Many of these features created API changes that are not backwards
compatible. Since (a) these are mostly changes to peripheral features,
and (b) AnyTemplate is a young module and (c) all of its users are
likely on this list, I don't plan to go to extraordinary lengths to
ensure backwards compatibility. I'd rather just make a clean break and
move on. But I'm willing to be talked out of this position. If any of
the changes above look like they're going to cause you a headache,
let me know.
Also - feedback on the new features would be most welcome. My biggest
questions at this point are:
* should the 'forward' method be in its own plugin so that anyone
can use it?
* is the ability to override C::A's built-in 'load_tmpl' method too
dangerous a feature?
CAP::AnyTemplate version 0.10_02 should be visible on search.cpan.org in
the next few hours. In the meantime, you can get it here:
http://occamstoothbrush.com/downloads/perl/CGI-Application-Plugin-AnyTemplate-0.10_02.tar.gz
Here's the changelog:
0.10_02 July 25, 2005 [**DEVELOPER RELEASE**]
- wrapped usage of CGI::Application's callback system in
if ($webapp->can('call_hook')) { ... }
...or equivalent, so CGI::Application 4.x is not required.
0.10_01 July 25, 2005 [**DEVELOPER RELEASE**]
- this version has several API changes that are not backwards compatible:
- template names used to be automatically determined from the name
of the calling subroutine:
sub my_runmode {
my $self = shift;
$self->other_method;
}
sub other_method {
my $self = shift;
$self->template->fill; # loads 'other_method.html'
}
There were two problems with this method:
1. Not every subroutine or method is a run mode
2. Under debuggers, the name of the calling subroutine is
often not available, so code that uses automatic
template names can't be run under a debugger.
So now AnyTemplate has been changed to get the template name
from $self->get_current_runmode:
sub my_runmode {
my $self = shift;
$self->other_method;
}
sub other_method {
my $self = shift;
$self->template->fill; # loads 'my_runmode.html'
}
If you want to pass control to another runmode and you want
$self->get_current_runmode to be updated, then you use the
new 'forward' method:
sub my_runmode {
my $self = shift;
return $self->forward('other_runmode');
}
sub other_runmode {
my $self = shift;
$self->template->fill; # loads 'other_runmode.html'
}
- template_pre_process and template_post_process are no longer
called automatically. Instead you must register them as
hooks.
$self->add_callback('template_pre_process', \&template_pre_process);
$self->add_callback('template_post_process', \&template_post_process);
- associate_query and emulate_associate_query have now been
disabled by default. Having this feature enabled by default
was a potential XSS (Cross Site Scripting) security risk.
The use of this feature is now deprecated. The feature
will be removed in the future
- other changes:
- added option to override load_tmpl. It is enabled by:
use CGI::Application::Plugin::AnyTemplate qw(load_tmpl);
When this feature is enabled, you can do the following:
$self->load_tmpl('somefile.txt',
path => '/path/to/templates',
%other_options
);
And this is translated into:
$self->template->load('somefile.txt',
add_include_path => '/path/to/templates',
HTMLTemplate => \%other_options,
auto_add_template_extension => 0,
);
- added support for the load_tmpl hook, compatible with the
one built into CGI::Application
- $self->tmpl_path is now merged into 'include_path'
- documentation for authors of plugins and re-usable applications
- documentation for why the automatic extension mechanism is there
- re-numbered some test scripts
0.08 July 20, 2005
- fixed bug where keys of configuration hashref were clobbered,
so if you used the same config repeatedly (e.g. under
mod_perl), onlyt the first call would work.
(thanks to R.A. Jones)
0.07 July 10, 2005
- templates can also be created from strings via fill:
return $self->template->fill(\$some_text, \%params);
0.06 July 10, 2005
- allowed templates to be created from strings (works in all
drivers except Petal):
$self->template->load(string => \$some_text);
$self->template->load(\$some_text);
0.05 Jun 15, 2005
- changed embedded components from 'dispatch' to 'embed' to
avoid confusion with CGI::Application::Dispatch
This is an incompatible API change, which hopefully won't
actually affect anybody since I don't think there are any
users of AnyTemplate yet.
The default syntax has changed from:
CGIAPP_dispatch, CGIAPP.dispatch, CGIAPP/dispatch, etc.
to:
CGIAPP_embed, CGIAPP.embed, CGIAPP/embed, etc.
The old syntax still works to embed components in TT and
Petal (but is undocumented). Users of HTML::Template and
HTML::Template::Expr can return to the old syntax by setting
embed_tag_name to 'cgiapp_dispatch'
Related API changes:
- CAP:AnyTemplate::Dispatcher has been renamed to
CAP:AnyTemplate::ComponentHandler
- the dispatcher_class option has been renamed to
component_handler class
- the dispatch_tag_name driver config key has been renamed to
embed_tag_name
0.04 May 19, 2005
- fixed Pod links and other minor doc issues
0.03 May 19, 2005
- Fixed one More POD NAME error
0.02 May 19, 2005
- Fixed NAME sections in driver POD
0.01 May 18, 2005
- Initial Release
Michael
---
Michael Graham <suppressed>
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.