use MRO::Compat;
use Scalar::Util qw/blessed weaken/;
-our $VERSION = '0.36';
+our $VERSION = '0.37';
$VERSION = eval $VERSION;
__PACKAGE__->mk_accessors('template');
__PACKAGE__->config(
# any TT configuration items go here
- INCLUDE_PATH => [
- MyApp->path_to( 'root', 'src' ),
- MyApp->path_to( 'root', 'lib' ),
- ],
TEMPLATE_EXTENSION => '.tt',
CATALYST_VAR => 'c',
TIMER => 0,
+ ENCODING => 'utf-8'
# Not set by default
PRE_PROCESS => 'config/main',
WRAPPER => 'site/wrapper',
expose_methods => [qw/method_in_view_class/],
);
+# add include path configuration in MyApp.pm
+
+ __PACKAGE__->config(
+ 'View::Web' => {
+ INCLUDE_PATH => [
+ __PACKAGE__->path_to( 'root', 'src' ),
+ __PACKAGE__->path_to( 'root', 'lib' ),
+ ],
+ },
+ );
+
# render view from lib/MyApp.pm or lib/MyApp::Controller::SomeController.pm
sub message : Global {
happens when the module is first loaded.
package MyApp::View::Web;
-
- use strict;
- use base 'Catalyst::View::TT';
+ use Moose;
+ extends 'Catalyst::View::TT';
__PACKAGE__->config({
- INCLUDE_PATH => [
- MyApp->path_to( 'root', 'templates', 'lib' ),
- MyApp->path_to( 'root', 'templates', 'src' ),
- ],
PRE_PROCESS => 'config/main',
WRAPPER => 'site/wrapper',
});
You may also override the configuration provided in the view class by adding
-a 'View::Web' section to your application config (either in the application
-main class, or in your configuration file). This should be reserved for
+a 'View::Web' section to your application config.
+
+This should generally be used to inject the include paths into the view to
+avoid the view trying to load the application to resolve paths.
+
+ .. inside MyApp.pm ..
+ __PACKAGE__->config(
+ 'View::Web' => {
+ INCLUDE_PATH => [
+ __PACKAGE__->path_to( 'root', 'templates', 'lib' ),
+ __PACKAGE__->path_to( 'root', 'templates', 'src' ),
+ ],
+ },
+ );
+
+You can also configure your view from within your config file if you're
+using L<Catalyst::Plugin::ConfigLoader>. This should be reserved for
deployment-specific concerns. For example:
# MyApp_local.conf (Config::General format)
having a C<additional_template_paths> key with a value of additonal directories
to search. See L<CAPTURING TEMPLATE OUTPUT> for an example showing this.
+=head2 Unicode
+
+Be sure to set C<< ENCODING => 'utf-8' >> and use
+L<Catalyst::Plugin::Unicode::Encoding> if you want to use non-ascii
+characters (encoded as utf-8) in your templates.
+
=head2 RENDERING VIEWS
The view plugin renders the template specified in the C<template>
Allows you to specify the template providers that TT will use.
- MyApp->config({
+ MyApp->config(
name => 'MyApp',
root => MyApp->path_to('root'),
'View::Web' => {
}
]
},
- });
+ );
The 'name' key should correspond to the class name of the provider you
want to use. The _file_ name is a special case that represents the default