Catalyst::View::HTML::CTPP2 - HTML::CTPP2 View Class
# 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');
This is the HTML::CTPP2 view class. Your subclass should inherit from this class.
HTML::CTPP2
Internally used by Catalyst. Used to configure some internal stuff.
Catalyst
Renders the template specified in $c->stash->{template} or $c->request->match. Template params are set up from the contents of $c->stash, augmented with base set to $c->req->base and name to $c->config->{name}. Output is stored in $c->response->body.
$c->stash->{template}
$c->request->match
$c->stash
base
$c->req->base
name
$c->config->{name}
$c->response->body
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 with base set to $c->req->base and name to $c->config->{name}.
%$args
This allows your view subclass to pass additional settings to the HTML::CTPP2 config-hash.
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 ':'.
INCLUDE_PATH
BLOCK
:
__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'.
/
\
C:\Blah Blah
Used to provide an alternative delimiter character sequence for separating paths specified in the INCLUDE_PATH. The default value for DELIMITER is ':'.
DELIMITER
__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.
C:/foo
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.
;
If TEMPLATE_EXTENSION is defined then use template files with the TEMPLATE_EXTENSION extension will be loaded. Default extension - '.ctpp2'
TEMPLATE_EXTENSION
.ctpp2
__PACKAGE__->config( TEMPLATE_EXTENSION => '.myext' );
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
file_cache_time
file_cache_dir
Set use caching or not. Integer (default - 0 [caching off]).
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 );
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.
1 hour
#set cache time 1 day __PACKAGE__->config( file_cache_time => 24*60*60 );
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' );
See here - HTML::CTPP2
HTML::CTPP2, Catalyst, Catalyst::Base.
Victor M Elfimov (victor@sols.ru)
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::View::HTML::CTPP2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::View::HTML::CTPP2
CPAN shell
perl -MCPAN -e shell install Catalyst::View::HTML::CTPP2
For more information on module installation, please visit the detailed CPAN module installation guide.