> 1. I have faced this problem only with HTML::FillInForm module. I also
> use templates with generating some complex SQL queries and I need output
> as a string, but there is no problem with dereferencing a scalarref.
>
> It looks very reasonable to me to let CAP::FillInForm accept both
> styles. Making returning a string by CAP::AnyTemplate as an option can
> be a little unnecessary and confusing.
Oh well - too late! I just added the 'return_references' option to
AnyTemplate. Ah well, this may be useful to people who use
HTML::FillInForm directly instead of using CAP::FillInForm.
The changes to the modules are:
CAP::FillInForm 1.14 (visible on CPAN shortly)
- with fill_form($html, ...), $html can now be either a scalarref or a
reference to a scalarref.
CAP::AnyTemplate 0.12 (visible on CPAN shortly)
- output() still returns a reference by default
- output() can return a string if you set the 'return_references'
option to false
- template object returned by load_tmpl() always returns a string,
since load_tmpl() is there for compatibility.
> 2. BTW, I would expect CAP::AnyTemplate to have a kind of 'add_config'
> function. After importing my default enterprise configuration into
> cgiapp_init with 'config' function I would like sometimes to change some
> options like paths, cache etc. just before loading a template.
>
> As far as I know 'config' function clears all parameters and replaces
> with new ones. IMO there is a need for a function, that is able to
> change or add new parameters to the configuration defined earlier.
Well, you can add config parameters to 'load'. This allows you to
override configuration values on a per-template basis:
my $template = $self->template->load(
file => 'some_file.tmpl',
type => 'HTMLTemplate',
auto_add_template_extension => 0,
add_include_path => '..',
HTMLTemplate => {
die_on_bad_params => 1,
},
);
BTW, as far as include_paths go, if you want to replace them, use:
my $template = $self->template->load(
include_path => '/some/new/path'
);
But if you want to merge new paths while keeping the ones you set up in
config, you can use 'add_include_paths':
my $template = $self->template->load(
add_include_path => '/some/additional/path'
);
Adding configuration options to 'load' only allows you to make
configuration changes for a single template. If you find that you want
to use your second template configuration for more than one template,
you can create a second named configuration:
# default configuration
$self->template->config(
default_type => 'HTMLTemplate',
);
# new configuration named 'foo'
$self->template('foo')->config(
default_type => 'TemplateToolkit',
);
Later on, in your runmodes:
# this uses the default config (HTML::Template)
$self->template->load('some_template');
# this uses the 'foo' config (Template Toolkit)
$self->template('foo')->load('some_template');
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.