NAME
Catalyst::View::HTML::CTPP2 - HTML::CTPP2 View Class
SYNOPSIS
# use the helper
create.pl view HTML::CTPP2 HTML::CTPP2
# lib/MyApp/View/HTML/CTPP2.pm
package MyApp::View::HTML::CTPP2;
use base 'Catalyst::View::HTML::CTPP2';
__PACKAGE__->config(
INCLUDE_PATH => [
MyApp->path_to( 'root', 'src' ),
MyApp->path_to( 'root', 'lib' )
),
TEMPLATE_EXTENSION => '.ctpp2c',
file_cache => 1,
file_cache_time => 24*60*60,
file_cache_dir => '/tmp/myapp_cache',
arg_stack_size => 1024,
.....
source_charset => 'CP1251',
destination_charset => 'utf-8'
);
1;
# Meanwhile, maybe in an 'end' action
$c->forward('MyApp::View::HTML::CTPP2');
DESCRIPTION
This is the HTML::CTPP2
view class. Your subclass should inherit from this class.
METHODS
- new
-
Internally used by
Catalyst
. Used to configure some internal stuff. - process
-
Renders the template specified in
$c->stash->{template}
or$c->request->match
. Template params are set up from the contents of$c->stash
, augmented withbase
set to$c->req->base
andname
to$c->config->{name}
. Output is stored in$c->response->body
. - render
-
Renders the given template and returns output. Template params are set up either from the contents of
%$args
if $args is a hashref, or$c->stash
, augmented withbase
set to$c->req->base
andname
to$c->config->{name}
. - config
-
This allows your view subclass to pass additional settings to the HTML::CTPP2 config-hash.
Template Configuration
PATH CONFIGURATION AND TEMPLATE EXTENSION
INCLUDE_PATH
The INCLUDE_PATH
is used to specify one or more directories in which template files are located. When a template is requested that isn't defined locally as a BLOCK
, each of the INCLUDE_PATH
directories is searched in turn to locate the template file. Multiple directories can be specified as a reference to a list or as a single string where each directory is delimited by ':
'.
__PACKAGE__->config(
INCLUDE_PATH => MyApp->path_to('root', 'src')
);
__PACKAGE__->config(
INCLUDE_PATH => '/myapp/path1:/myapp/path2:path3'
);
__PACKAGE__->config(
INCLUDE_PATH => [
MyApp->path_to('root', 'src'),
MyApp->path_to('root', 'lib')
]
);
On Win32 systems, a little extra magic is invoked, ignoring delimiters that have ':
' followed by a '/
' or '\
'. This avoids confusion when using directory names like 'C:\Blah Blah
'.
DELIMITER
Used to provide an alternative delimiter character sequence for separating paths specified in the INCLUDE_PATH
. The default value for DELIMITER
is ':
'.
__PACKAGE__->config(
DELIMITER => '; ',
INCLUDE_PATH => '/myapp/path1;/myapp/path2;path3'
);
On Win32 systems, the default delimiter is a little more intelligent, splitting paths only on ':
' characters that aren't followed by a '/
'. This means that the following should work as planned, splitting the INCLUDE_PATH
into 2 separate directories, C:/foo
and C:/bar
.
# on Win32 only
__PACKAGE__->config(
INCLUDE_PATH => 'C:/Foo:C:/Bar'
);
However, if you're using Win32 then it's recommended that you explicitly set the DELIMITER
character to something else (e.g. ';
') rather than rely on this subtle magic.
TEMPLATE_EXTENSION
If TEMPLATE_EXTENSION
is defined then use template files with the TEMPLATE_EXTENSION
extension will be loaded. Default extension - '.ctpp2
'
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.myext'
);
CACHING
If any of parameters file_cache
( and > 0 ), file_cache_time
, file_cache_dir
is defined - cache will be used. Default value - caching is off.
file_cache
Set use caching or not. Integer (default - 0 [caching off]
).
#caching is on
__PACKAGE__->config(
file_cache => 1,
file_cache_time => 24*60*60,
file_cache_dir => '/tmp/myapp_cache'
);
#caching is off
__PACKAGE__->config(
file_cache => 0,
file_cache_time => 24*60*60
);
file_cache_time
This value can be set to control how many long the template cached before checking to see if the source template has changed. Default cache time - 1 hour
.
#set cache time 1 day
__PACKAGE__->config(
file_cache_time => 24*60*60
);
file_cache_dir
The file_cache_dir
option is used to specify an alternate directory which compiled template files should be saved.
#set cache directory
#is '/tmp/catalysts/myapp'
__PACKAGE__->config(
file_cache_dir => '/tmp/catalysts/myapp'
);
CTPP2-Params
See here - HTML::CTPP2
SEE ALSO
HTML::CTPP2, Catalyst, Catalyst::Base.
AUTHOR
Victor M Elfimov (victor@sols.ru)
COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.