[Catalyst] HOWTO reference config settings from template
Robert 'phaylon' Sedlacek
rs at 474.at
Fri Apr 13 20:29:00 GMT 2007
Jeff Chimene said:
> Thanks for your reply. As I indicated in an earlier message
> (http://www.mail-archive.com/catalyst@lists.rawmode.org/msg04690.html),
> I've tried Dumper. I certainly get c.config values, but none of them are
> TT2 configuration settings. I'm using a view generated by the catalyst
> helper script.
When you do
__PACKAGE__->config(foo => 'bar');
in your controller, that setting never reaches the application configuration.
Settings in your configuration file are available via $c->config, or [%
c.config %] in TT. You can configure components (read: models, views and
controllers) from this file via (example in YAML):
View::TT:
ERROR: 'whatever'
The 'View::TT' configuration will be pushed to your 'MyApp::View::TT'
component. It will there be merged with the local component configuration
directly in the package. E.g.
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.html',
);
The merged configuration will be usually (if not implemented otherwise) in
the controller instance directly. So the best way might be
package MyApp::View::TT
...
sub the_config_you_want {
my ($self) = @_;
return $self->{the_config_you_want};
}
and then in the template
[% c.view('TT').the_config_you_want %]
HTH,
.phaylon
--
# Robert 'phaylon' Sedlacek
# Perl 5/Catalyst Developer in Hamburg, Germany
{ EMail => ' rs at 474.at ', Web => ' http://474.at ' }
More information about the Catalyst
mailing list