Catalyst-View-TT-0.45/000755 000000 000000 00000000000 13706046502 014565 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/README000644 000000 000000 00000044436 13706046501 015457 0ustar00rootwheel000000 000000 NAME Catalyst::View::TT - Template View Class SYNOPSIS # use the helper to create your View myapp_create.pl view Web TT # add custom configuration in View/Web.pm __PACKAGE__->config( # any TT configuration items go here TEMPLATE_EXTENSION => '.tt', CATALYST_VAR => 'c', TIMER => 0, ENCODING => 'utf-8' # Not set by default PRE_PROCESS => 'config/main', WRAPPER => 'site/wrapper', render_die => 1, # Default for new apps, see render method docs 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 { my ( $self, $c ) = @_; $c->stash->{template} = 'message.tt2'; $c->stash->{message} = 'Hello World!'; $c->forward( $c->view('Web') ); } # access variables from template The message is: [% message %]. # example when CATALYST_VAR is set to 'Catalyst' Context is [% Catalyst %] The base is [% Catalyst.req.base %] The name is [% Catalyst.config.name %] # example when CATALYST_VAR isn't set Context is [% c %] The base is [% base %] The name is [% name %] DESCRIPTION This is the Catalyst view class for the Template Toolkit. Your application should defined a view class which is a subclass of this module. Throughout this manual it will be assumed that your application is named MyApp and you are creating a TT view named Web; these names are placeholders and should always be replaced with whatever name you've chosen for your application and your view. The easiest way to create a TT view class is through the myapp_create.pl script that is created along with the application: $ script/myapp_create.pl view Web TT This creates a MyApp::View::Web.pm module in the lib directory (again, replacing "MyApp" with the name of your application) which looks something like this: package FooBar::View::Web; use Moose; extends 'Catalyst::View::TT'; __PACKAGE__->config(DEBUG => 'all'); Now you can modify your action handlers in the main application and/or controllers to forward to your view class. You might choose to do this in the end() method, for example, to automatically forward all actions to the TT view class. # In MyApp or MyApp::Controller::SomeController sub end : Private { my( $self, $c ) = @_; $c->forward( $c->view('Web') ); } But if you are using the standard auto-generated end action, you don't even need to do this! # in MyApp::Controller::Root sub end : ActionClass('RenderView') {} # no need to change this line # in MyApp.pm __PACKAGE__->config( ... default_view => 'Web', ); This will Just Work. And it has the advantages that: * If you want to use a different view for a given request, just set << $c->stash->{current_view} >>. (See Catalyst's "$c->view" method for details. * << $c->res->redirect >> is handled by default. If you just forward to "View::Web" in your "end" routine, you could break this by sending additional content. See Catalyst::Action::RenderView for more details. CONFIGURATION There are a three different ways to configure your view class. The first way is to call the "config()" method in the view subclass. This happens when the module is first loaded. package MyApp::View::Web; use Moose; extends 'Catalyst::View::TT'; __PACKAGE__->config({ 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. 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 Catalyst::Plugin::ConfigLoader. This should be reserved for deployment-specific concerns. For example: # MyApp_local.conf (Config::General format) WRAPPER "custom_wrapper" INCLUDE_PATH __path_to('root/templates/custom_site')__ INCLUDE_PATH __path_to('root/templates')__ might be used as part of a simple way to deploy different instances of the same application with different themes. DYNAMIC INCLUDE_PATH Sometimes it is desirable to modify INCLUDE_PATH for your templates at run time. Additional paths can be added to the start of INCLUDE_PATH via the stash as follows: $c->stash->{additional_template_paths} = [$c->config->{root} . '/test_include_path']; If you need to add paths to the end of INCLUDE_PATH, there is also an include_path() accessor available: push( @{ $c->view('Web')->include_path }, qw/path/ ); Note that if you use include_path() to add extra paths to INCLUDE_PATH, you MUST check for duplicate paths. Without such checking, the above code will add "path" to INCLUDE_PATH at every request, causing a memory leak. A safer approach is to use include_path() to overwrite the array of paths rather than adding to it. This eliminates both the need to perform duplicate checking and the chance of a memory leak: @{ $c->view('Web')->include_path } = qw/path another_path/; If you are calling "render" directly then you can specify dynamic paths by having a "additional_template_paths" key with a value of additional directories to search. See "CAPTURING TEMPLATE OUTPUT" for an example showing this. Unicode (pre Catalyst v5.90080) NOTE Starting with Catalyst v5.90080 unicode and encoding has been baked into core, and the default encoding is UTF-8. The following advice is for older versions of Catalyst. Be sure to set "ENCODING => 'utf-8'" and use Catalyst::Plugin::Unicode::Encoding if you want to use non-ascii characters (encoded as utf-8) in your templates. This is only needed if you actually have UTF8 literals in your templates and the BOM is not properly set. Setting encoding here does not magically encode your template output. If you are using this version of Catalyst you need to all the Unicode plugin, or upgrade (preferred) Unicode (Catalyst v5.90080+) This version of Catalyst will automatically encode your body output to UTF8. This means if your variables contain multibyte characters you don't need top do anything else to get UTF8 output. However if your templates contain UTF8 literals (like, multibyte characters actually in the template text), then you do need to either set the BOM mark on the template file or instruct TT to decode the templates at load time via the ENCODING configuration setting. Most of the time you can just do: MyApp::View::HTML->config( ENCODING => 'UTF-8'); and that will just take care of everything. This configuration setting will force Template to decode all files correctly, so that when you hit the finalize_encoding step we can properly encode the body as UTF8. If you fail to do this you will get double encoding issues in your output (but again, only for the UTF8 literals in your actual template text.) Again, this ENCODING configuration setting only instructs template toolkit how (and if) to decode the contents of your template files when reading them from disk. It has no other effect. RENDERING VIEWS The view plugin renders the template specified in the "template" item in the stash. sub message : Global { my ( $self, $c ) = @_; $c->stash->{template} = 'message.tt2'; $c->forward( $c->view('Web') ); } If a stash item isn't defined, then it instead uses the stringification of the action dispatched to (as defined by $c->action) in the above example, this would be "message", but because the default is to append '.tt', it would load "root/message.tt". The items defined in the stash are passed to the Template Toolkit for use as template variables. sub default : Private { my ( $self, $c ) = @_; $c->stash->{template} = 'message.tt2'; $c->stash->{message} = 'Hello World!'; $c->forward( $c->view('Web') ); } A number of other template variables are also added: c A reference to the context object, $c base The URL base, from $c->req->base() name The application name, from $c->config->{ name } These can be accessed from the template in the usual way: : The message is: [% message %] The base is [% base %] The name is [% name %] The output generated by the template is stored in "$c->response->body". CAPTURING TEMPLATE OUTPUT If you wish to use the output of a template for some other purpose than displaying in the response, e.g. for sending an email, this is possible using other views, such as Catalyst::View::Email::Template. TEMPLATE PROFILING See ""TIMER"" property of the "config" method. METHODS new The constructor for the TT view. Sets up the template provider, and reads the application config. process($c) Renders the template specified in "$c->stash->{template}" or "$c->action" (the private name of the matched action). Calls render to perform actual rendering. Output is stored in "$c->response->body". It is possible to forward to the process method of a TT view from inside Catalyst like this: $c->forward('View::Web'); N.B. This is usually done automatically by Catalyst::Action::RenderView. render($c, $template, \%args) Renders the given template and returns output. Throws a Template::Exception object upon error. The template variables are set to %$args if $args is a hashref, or "$c->stash" otherwise. In either case the variables are augmented with "base" set to "$c->req->base", "c" to $c, and "name" to "$c->config->{name}". Alternately, the "CATALYST_VAR" configuration item can be defined to specify the name of a template variable through which the context reference ($c) can be accessed. In this case, the "c", "base", and "name" variables are omitted. $template can be anything that Template::process understands how to process, including the name of a template file or a reference to a test string. See Template::process for a full list of supported formats. To use the render method outside of your Catalyst app, just pass a undef context. This can be useful for tests, for instance. It is possible to forward to the render method of a TT view from inside Catalyst to render page fragments like this: my $fragment = $c->forward("View::Web", "render", $template_name, $c->stash->{fragment_data}); Backwards compatibility note The render method used to just return the Template::Exception object, rather than just throwing it. This is now deprecated and instead the render method will throw an exception for new applications. This behaviour can be activated (and is activated in the default skeleton configuration) by using "render_die => 1". If you rely on the legacy behaviour then a warning will be issued. To silence this warning, set "render_die => 0", but it is recommended you adjust your code so that it works with "render_die => 1". In a future release, "render_die => 1" will become the default if unspecified. template_vars Returns a list of keys/values to be used as the catalyst variables in the template. config This method allows your view subclass to pass additional settings to the TT configuration hash, or to set the options as below: paths The list of paths TT will look for templates in. expose_methods The list of methods in your View class which should be made available to the templates. For example: expose_methods => [qw/uri_for_css/], ... sub uri_for_css { my ($self, $c, $filename) = @_; # additional complexity like checking file exists here return $c->uri_for('/static/css/' . $filename); } Then in the template: [% uri_for_css('home.css') %] content_type This lets you override the default content type for the response. If you do not set this and if you do not set the content type in your controllers, the default is "text/html; charset=utf-8". Use this if you are creating alternative view responses, such as text or JSON and want a global setting. Any content type set in your controllers before calling this view are respected and have priority. "CATALYST_VAR" Allows you to change the name of the Catalyst context object. If set, it will also remove the base and name aliases, so you will have access them through . For example, if CATALYST_VAR has been set to "Catalyst", a template might contain: The base is [% Catalyst.req.base %] The name is [% Catalyst.config.name %] "TIMER" If you have configured Catalyst for debug output, and turned on the TIMER setting, "Catalyst::View::TT" will enable profiling of template processing (using Template::Timer). This will embed HTML comments in the output from your templates, such as: .... "TEMPLATE_EXTENSION" a suffix to add when looking for templates bases on the "match" method in Catalyst::Request. For example: package MyApp::Controller::Test; sub test : Local { .. } Would by default look for a template in /test/test. If you set TEMPLATE_EXTENSION to '.tt', it will look for /test/test.tt. "PROVIDERS" Allows you to specify the template providers that TT will use. MyApp->config( name => 'MyApp', root => MyApp->path_to('root'), 'View::Web' => { PROVIDERS => [ { name => 'DBI', args => { DBI_DSN => 'dbi:DB2:books', DBI_USER=> 'foo' } }, { name => '_file_', args => {} } ] }, ); 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 TT file-based provider. By default the name is will be prefixed with 'Template::Provider::'. You can fully qualify the name by using a unary plus: name => '+MyApp::Provider::Foo' You can also specify the 'copy_config' key as an arrayref, to copy those keys from the general config, into the config for the provider: DEFAULT_ENCODING => 'utf-8', PROVIDERS => [ { name => 'Encoding', copy_config => [qw(DEFAULT_ENCODING INCLUDE_PATH)] } ] This can prove useful when you want to use the additional_template_paths hack in your own provider, or if you need to use Template::Provider::Encoding "CLASS" Allows you to specify a custom class to use as the template class instead of Template. package MyApp::View::Web; use Moose; extends 'Catalyst::View::TT'; use Template::AutoFilter; __PACKAGE__->config({ CLASS => 'Template::AutoFilter', }); This is useful if you want to use your own subclasses of Template, so you can, for example, prevent XSS by automatically filtering all output through "| html". HELPERS The Catalyst::Helper::View::TT and Catalyst::Helper::View::TTSite helper modules are provided to create your view module. There are invoked by the myapp_create.pl script: $ script/myapp_create.pl view Web TT $ script/myapp_create.pl view Web TTSite The Catalyst::Helper::View::TT module creates a basic TT view module. The Catalyst::Helper::View::TTSite module goes a little further. It also creates a default set of templates to get you started. It also configures the view module to locate the templates automatically. NOTES If you are using the CGI module inside your templates, you will experience that the Catalyst server appears to hang while rendering the web page. This is due to the debug mode of CGI (which is waiting for input in the terminal window). Turning off the debug mode using the "-no_debug" option solves the problem, eg.: [% USE CGI('-no_debug') %] SEE ALSO Catalyst, Catalyst::Helper::View::TT, Catalyst::Helper::View::TTSite, Template::Manual AUTHORS Sebastian Riedel, "sri@cpan.org" Marcus Ramberg, "mramberg@cpan.org" Jesse Sheidlower, "jester@panix.com" Andy Wardley, "abw@cpan.org" Luke Saunders, "luke.saunders@gmail.com" COPYRIGHT This program is free software. You can redistribute it and/or modify it under the same terms as Perl itself. Catalyst-View-TT-0.45/Changes000644 000000 000000 00000016663 13706046431 016075 0ustar00rootwheel000000 000000 Revision history for Perl extension Catalyst::View::TT. 0.45 - 2020-07-22 - specify correct Test::More prereq - correct links in POD (PR#3) - silence warnings in tests 0.44 - 2015-10-05 - declare missing prereq on Data::Dump 0.43 - 2015-08-13 - remove mention of deprecated Catalyst::Plugin::Email in documentation 0.42 2014-12-29 - Fixes to test cases to be compatible with Catalyst v5.90080 - Added a Unicode test designed to check new Catalyst function - Docs for above 0.41 2013-02-28 - New local attribute to let you override the default content type when no content type has been set for the response. 0.40 2013-01-15 20:52:14 - Fix hash randomisation breakage in tests (RT#82703) 0.39 2012-04-11 07:40:00 - Fix warning from tests. RT#75104 - Fix ExtUtils::MakeMaker version requirement (due to last release being made with faulty Module::Install). RT#76488 0.38 2012-02-15 20:42:00 - Change documentation to reflect use of Moose. - Change documentation to highlight how to configure UTF-8 in templates. - Change documentation to recommend putting calls to MyApp->path_to into the app class itself, ergo avoiding recursive dependencies and making the view compile standalone. - Change code generated by Catalyst::Helper::View::TT to use Moose. 0.37 2011-07-17 09:20:00 - Allow setting of TT class rather than forcing 'Template' 0.36 2010-10-19 15:00:00 - Fixed subclassing when using expose_methods 0.35 2010-08-26 01:38:00 - Add expose_methods functionality - add template name to exceptions - update render_die message to be more concise. - Doc fixes (RT#57159) - Silence warnings about Template::Provider::Encoding (RT #56310) 0.34 2010-04-07 04:14:50 - Fix the process method to have the previous behaviour of reporting an error to Catalyst if a Template::Exception object is returned by the render method (i.e. when render_die is unset or set to 0). - Fix the warning issued about missing the render_die config option to log using the standard Catalyst logging system (rather than Carping directly), and to only issue the warning at debug level / when in debug mode. The severity of this warning will be increased in a later release. 0.33 2010-03-10 20:08:00 - The "render()" method now throws a warning on exception before returning the exception. To silence the warning, pass 'render_die => 0' to the constructor. Better yet, pass 'render_die => 1' to make it die instead of returning the excption. This will be the default in a future release when unspecified. The Helper will generate new views with render_die => 1. 0.32 2010-02-16 05:55:00 - Various documentation improvements. - Fix repository metadata. 0.31 2009-10-29 19:26:00 - Moved the test actions to their own controller file to silence warning about actions in the app class being deprecated. 0.30 2009-09-12 23:47:00 - Doc fixes: + Expand ::V:: to ::View:: (RT #45792) + Expand ::C:: to ::Controller:: and use $c->view('TT') where appropriate (bricas) + Add note about use CGI in a template making Catalyst hang (Gunnar Strand) - "use warnings" in Catalyst::View::TT and output from the TT helper - Expand TTSite documentation (RT #33838) - Added a test for direct rendering of a template from a view object, without a request. - Added support for running render with a undef context. 0.29 2009-02-20 14:43:00 - Remove extra unwanted .gitignore from manifest 0.28 2009-02-17 20:37:00 - Change from NEXT to MRO::Compat (t0m) - fix pod generated by the helper (RT #33983) - remove stray newline from generated lib/config/col template (RT #35340) 0.27 2008-04-30 12:30:00 - Add copy_config support to PROVIDERS - Document providers and support unary plus for fully qualified class names as in the example in TT pod. 0.26 2008-01-11 20:12:00 - Fix pod coverage - Change from =item to =head2 - Update docs to reflect action change 0.25 2007-01-15 16:06 - The little typo that cold 0.24 2006-11-15 16:34 - Default to .tt extension - pod cleanups for generated file - Move to Module::Install - Use Data::Dump for debug 0.23 Sun Mar 23 20:45:00 2006 - Added render suport. (Ash Berlin) 0.22 Fri Jan 16 18:25:00 2006 - stringify $c->action for automatic template match instead of $c->req->action. * NOTE * This will change the match to the private name of the matched action! if you use template_suffix you have to move your templates around! 0.21 Fri Dec 16 18:25:00 2005 - Added Template::Provider support (Jess Robinson) - Fixed dynamic include bugs and added tests. (Zbigniew Lukasiak) 0.20 Mon Dec 12 03:35:00 2005 - Fall back to action (default/index returns blank on match) - Added tests. (Daniel Westermann-Clark) - Fixed TTSite helper to use correct app name. - Added support for dynamic includes. 0.19 Tue Nov 15 09:52:00 2005 - unbreak config. 0.18 Mon Nov 14 20:43:00 2005 - Fixed more typos 0.17 Mon Nov 14 20:43:00 2005 - Fixed some typos 0.16 Mon Nov 14 20:43:00 2005 - Updated TTSite for Catalyst 5.5 0.15 Mon Nov 14 14:43:00 2005 - Updated for Catalyst 5.5 - Fix docs - Added TEMPLATE_SUFFIX config variable 0.14 Fri Oct 21 10:20:00 2005 - Turn timer off by default, even for debug. - removed superflous 'templates' inside 'root' - made it possible to forward to the message action by passing the message in the stash. (example) - Updated docs to show correct config syntax. 0.13 Fri Oct 07 13:30:00 2005 - Fixed constructor - Big update by Andy Wardley - Much improved docs 0.12 Wed Jul 06 15:24:00 2005 - Fixed, don't set Content-Type on failure - Fixed helper to use [%author%] - Fixed helper templates - Rewrote docs 0.11 Fri Apr 15 16:00:00 2005 - Fixed broken helper. 0.10 Fri Apr 15 16:00:00 2005 - Added POD tests and made them pass. - updated for Catalyst 5 - New TT Helpers. 0.09 Wed Mar 29 13:47:00 2005 - Don't override user-set charset/content-type - Cleaned up the content-type we set. - Updated README to current POD to current POD 0.08 Wed Mar 29 12:22:00 2005 - changed order of stash so stash can override c/base/name - fixed some typos - extended the documentation (Andrew Ford) 0.07 Sat Mar 04 23:00:00 2005 - fixed the bugs produced by draven and the_jester ;) 0.06 Fri Mar 04 20:00:00 2005 - new helper api 0.05 Mon Feb 28 10:00:00 2005 - added helper 0.04 Sun Feb 27 22:00:00 2005 - better debug messages (Marcus Ramberg) 0.03 Thu Feb 17 22:00:00 2005 - don't try to render something without a template 0.02 Tue Feb 01 02:00:00 2005 - using $c->req->match instead of $c->req->action 0.01 Fri Jan 28 22:00:00 2005 - first release Catalyst-View-TT-0.45/MANIFEST000644 000000 000000 00000002744 13706046502 015725 0ustar00rootwheel000000 000000 Changes lib/Catalyst/Helper/View/TT.pm lib/Catalyst/Helper/View/TTSite.pm lib/Catalyst/View/TT.pm maint/Makefile.PL.include Makefile.PL MANIFEST This list of files t/01use.t t/04pkgconfig.t t/05appconfig.t t/06includepath.t t/07render.t t/08cycle.t t/09providers.t t/10providers.encoding.t t/11norequest.t t/12expose_methods.t t/13classconfig.t t/14alt_content_type.t t/lib/TestApp.pm t/lib/TestApp/Controller/Root.pm t/lib/TestApp/FauxProvider.pm t/lib/TestApp/root/any_include_path/test t/lib/TestApp/root/expose_methods.tt t/lib/TestApp/root/specified_template.tt t/lib/TestApp/root/test.tt t/lib/TestApp/root/test_alt_content_type.tt t/lib/TestApp/root/test_include_path/testpath.tt t/lib/TestApp/Template/Any.pm t/lib/TestApp/View/TT/AltContentType.pm t/lib/TestApp/View/TT/Appconfig.pm t/lib/TestApp/View/TT/Classconfig.pm t/lib/TestApp/View/TT/Encoding.pm t/lib/TestApp/View/TT/ExposeMethods.pm t/lib/TestApp/View/TT/ExposeMethodsSubclassed.pm t/lib/TestApp/View/TT/Includepath.pm t/lib/TestApp/View/TT/Includepath2.pm t/lib/TestApp/View/TT/Includepath3.pm t/lib/TestApp/View/TT/Pkgconfig.pm t/lib/TestApp/View/TT/Providerconfig.pm t/root/heart t/utf8.t xt/pod-coverage.t xt/pod-syntax.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) LICENSE LICENSE file (added by Distar) Catalyst-View-TT-0.45/LICENSE000644 000000 000000 00000043425 13706046502 015602 0ustar00rootwheel000000 000000 Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2020 by Sebastian Riedel . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2020 by Sebastian Riedel . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Catalyst-View-TT-0.45/t/000755 000000 000000 00000000000 13706046477 015043 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/xt/000755 000000 000000 00000000000 13706046477 015233 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/META.yml000644 000000 000000 00000001744 13706046500 016042 0ustar00rootwheel000000 000000 --- abstract: 'Template View Class' author: - 'Sebastian Riedel ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' Test::More: '0.88' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Catalyst-View-TT no_index: directory: - t - inc requires: Catalyst: '5.7' Class::Accessor: '0' Data::Dump: '0' MRO::Compat: '0' Path::Class: '0' Template: '0' Template::Timer: '0' perl: '5.008001' resources: IRC: irc://irc.perl.org/#catalyst MailingList: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-View-TT repository: https://github.com/perl-catalyst/Catalyst-View-TT.git version: '0.45' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Catalyst-View-TT-0.45/META.json000644 000000 000000 00000003432 13706046501 016207 0ustar00rootwheel000000 000000 { "abstract" : "Template View Class", "author" : [ "Sebastian Riedel " ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Catalyst-View-TT", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Catalyst" : "5.7", "Class::Accessor" : "0", "Data::Dump" : "0", "MRO::Compat" : "0", "Path::Class" : "0", "Template" : "0", "Template::Timer" : "0", "perl" : "5.008001" } }, "test" : { "requires" : { "File::Spec" : "0", "Test::More" : "0.88" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Catalyst-View-TT@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-View-TT" }, "repository" : { "type" : "git", "url" : "https://github.com/perl-catalyst/Catalyst-View-TT.git", "web" : "https://github.com/perl-catalyst/Catalyst-View-TT" }, "x_IRC" : "irc://irc.perl.org/#catalyst", "x_MailingList" : "http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" }, "version" : "0.45", "x_serialization_backend" : "JSON::PP version 4.04" } Catalyst-View-TT-0.45/lib/000755 000000 000000 00000000000 13706046477 015346 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/maint/000755 000000 000000 00000000000 13706046477 015710 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/Makefile.PL000644 000000 000000 00000005133 13705324676 016553 0ustar00rootwheel000000 000000 use strict; use warnings; use ExtUtils::MakeMaker; ExtUtils::MakeMaker->VERSION('7.00') unless -f 'META.yml'; (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; my %WriteMakefileArgs = ( NAME => 'Catalyst::View::TT', VERSION_FROM => 'lib/Catalyst/View/TT.pm', AUTHOR => 'Sebastian Riedel ', LICENSE => 'perl_5', MIN_PERL_VERSION => 5.008001, # catalyst minimum PREREQ_PM => { 'Catalyst' => '5.7', 'Template' => 0, 'Class::Accessor' => 0, 'Template::Timer' => 0, 'Path::Class' => 0, 'MRO::Compat' => 0, 'Data::Dump' => 0, }, TEST_REQUIRES => { 'Test::More' => '0.88', 'File::Spec' => '0', }, META_MERGE => { 'meta-spec' => { version => 2 }, dynamic_config => 0, resources => { # r/w: catagits@git.shadowcat.co.uk:Catalyst-View-TT # r/o: git://git.shadowcat.co.uk:catagits/Catalyst-View-TT # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/Catalyst-View-TT.git repository => { url => 'https://github.com/perl-catalyst/Catalyst-View-TT.git', web => 'https://github.com/perl-catalyst/Catalyst-View-TT', type => 'git', }, bugtracker => { mailto => 'bug-Catalyst-View-TT@rt.cpan.org', web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-View-TT', }, x_MailingList => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst', x_IRC => 'irc://irc.perl.org/#catalyst', }, }, ); die 'need to do a merge with CPAN::Meta::Requirements!!' if !-f 'META.yml' && exists $WriteMakefileArgs{BUILD_REQUIRES}; if (!eval { ExtUtils::MakeMaker->VERSION('6.6303') }) { $WriteMakefileArgs{BUILD_REQUIRES} = $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{TEST_REQUIRES}; } if (!eval { ExtUtils::MakeMaker->VERSION('6.5501') }) { @{$WriteMakefileArgs{PREREQ_PM}}{ keys %{$WriteMakefileArgs{BUILD_REQUIRES}} } = @{$WriteMakefileArgs{BUILD_REQUIRES}}{ keys %{$WriteMakefileArgs{BUILD_REQUIRES}} }; delete $WriteMakefileArgs{BUILD_REQUIRES}; } my %mm_req = ( LICENCE => 6.31, META_MERGE => 6.45, META_ADD => 6.45, MIN_PERL_VERSION => 6.48, ); for (keys %mm_req) { unless (eval { ExtUtils::MakeMaker->VERSION($mm_req{$_}) }) { warn "$_ $@" if not -f 'Makefile.PL'; delete $WriteMakefileArgs{$_}; } } WriteMakefile(%WriteMakefileArgs); Catalyst-View-TT-0.45/maint/Makefile.PL.include000644 000000 000000 00000000445 13705324562 021300 0ustar00rootwheel000000 000000 use strict; use warnings; BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") } use lib 'Distar/lib'; use Distar; manifest_include( 't/lib' => '.tt', 't/lib' => 'test', 't/root' => 'heart', ); 1; # vim: set ft=perl ts=8 sts=4 sw=4 tw=115 et : Catalyst-View-TT-0.45/lib/Catalyst/000755 000000 000000 00000000000 13706046477 017132 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/lib/Catalyst/Helper/000755 000000 000000 00000000000 13706046477 020351 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/lib/Catalyst/View/000755 000000 000000 00000000000 13706046477 020044 5ustar00rootwheel000000 000000 Catalyst-View-TT-0.45/lib/Catalyst/View/TT.pm000644 000000 000000 00000061210 13705337303 020717 0ustar00rootwheel000000 000000 package Catalyst::View::TT; use strict; use warnings; use base qw/Catalyst::View/; use Data::Dump 'dump'; use Template; use Template::Timer; use MRO::Compat; use Scalar::Util qw/blessed weaken/; our $VERSION = '0.45'; $VERSION =~ tr/_//d; __PACKAGE__->mk_accessors('template'); __PACKAGE__->mk_accessors('expose_methods'); __PACKAGE__->mk_accessors('include_path'); __PACKAGE__->mk_accessors('content_type'); *paths = \&include_path; =head1 NAME Catalyst::View::TT - Template View Class =head1 SYNOPSIS # use the helper to create your View myapp_create.pl view Web TT # add custom configuration in View/Web.pm __PACKAGE__->config( # any TT configuration items go here TEMPLATE_EXTENSION => '.tt', CATALYST_VAR => 'c', TIMER => 0, ENCODING => 'utf-8' # Not set by default PRE_PROCESS => 'config/main', WRAPPER => 'site/wrapper', render_die => 1, # Default for new apps, see render method docs 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 { my ( $self, $c ) = @_; $c->stash->{template} = 'message.tt2'; $c->stash->{message} = 'Hello World!'; $c->forward( $c->view('Web') ); } # access variables from template The message is: [% message %]. # example when CATALYST_VAR is set to 'Catalyst' Context is [% Catalyst %] The base is [% Catalyst.req.base %] The name is [% Catalyst.config.name %] # example when CATALYST_VAR isn't set Context is [% c %] The base is [% base %] The name is [% name %] =cut sub _coerce_paths { my ( $paths, $dlim ) = shift; return () if ( !$paths ); return @{$paths} if ( ref $paths eq 'ARRAY' ); # tweak delim to ignore C:/ unless ( defined $dlim ) { $dlim = ( $^O eq 'MSWin32' ) ? ':(?!\\/)' : ':'; } return split( /$dlim/, $paths ); } sub new { my ( $class, $c, $arguments ) = @_; my $config = { EVAL_PERL => 0, TEMPLATE_EXTENSION => '', CLASS => 'Template', %{ $class->config }, %{$arguments}, }; if ( ! (ref $config->{INCLUDE_PATH} eq 'ARRAY') ) { my $delim = $config->{DELIMITER}; my @include_path = _coerce_paths( $config->{INCLUDE_PATH}, $delim ); if ( !@include_path ) { my $root = $c->config->{root}; my $base = Path::Class::dir( $root, 'base' ); @include_path = ( "$root", "$base" ); } $config->{INCLUDE_PATH} = \@include_path; } # if we're debugging and/or the TIMER option is set, then we install # Template::Timer as a custom CONTEXT object, but only if we haven't # already got a custom CONTEXT defined if ( $config->{TIMER} ) { if ( $config->{CONTEXT} ) { $c->log->error( 'Cannot use Template::Timer - a TT CONTEXT is already defined' ); } else { $config->{CONTEXT} = Template::Timer->new(%$config); } } if ( $c->debug && $config->{DUMP_CONFIG} ) { $c->log->debug( "TT Config: ", dump($config) ); } my $self = $class->next::method( $c, { %$config }, ); # Set base include paths. Local'd in render if needed $self->include_path($config->{INCLUDE_PATH}); $self->expose_methods($config->{expose_methods}); $self->config($config); # Creation of template outside of call to new so that we can pass [ $self ] # as INCLUDE_PATH config item, which then gets ->paths() called to get list # of include paths to search for templates. # Use a weakened copy of self so we don't have loops preventing GC from working my $copy = $self; Scalar::Util::weaken($copy); $config->{INCLUDE_PATH} = [ sub { $copy->paths } ]; if ( $config->{PROVIDERS} ) { my @providers = (); if ( ref($config->{PROVIDERS}) eq 'ARRAY') { foreach my $p (@{$config->{PROVIDERS}}) { my $pname = $p->{name}; my $prov = 'Template::Provider'; if($pname eq '_file_') { $p->{args} = { %$config }; } else { if($pname =~ s/^\+//) { $prov = $pname; } else { $prov .= "::$pname"; } # We copy the args people want from the config # to the args $p->{args} ||= {}; if ($p->{copy_config}) { map { $p->{args}->{$_} = $config->{$_} } grep { exists $config->{$_} } @{ $p->{copy_config} }; } } local $@; eval "require $prov"; if(!$@) { push @providers, "$prov"->new($p->{args}); } else { $c->log->warn("Can't load $prov, ($@)"); } } } delete $config->{PROVIDERS}; if(@providers) { $config->{LOAD_TEMPLATES} = \@providers; } } $self->{template} = $config->{CLASS}->new($config) || do { my $error = $config->{CLASS}->error(); $c->log->error($error); $c->error($error); return undef; }; return $self; } sub process { my ( $self, $c ) = @_; my $template = $c->stash->{template} || $c->action . $self->config->{TEMPLATE_EXTENSION}; unless (defined $template) { $c->log->debug('No template specified for rendering') if $c->debug; return 0; } local $@; my $output = eval { $self->render($c, $template) }; if (my $err = $@) { return $self->_rendering_error($c, $template . ': ' . $err); } if (blessed($output) && $output->isa('Template::Exception')) { $self->_rendering_error($c, $output); } unless ( $c->response->content_type ) { my $default = $self->content_type || 'text/html; charset=UTF-8'; $c->response->content_type($default); } $c->response->body($output); return 1; } sub _rendering_error { my ($self, $c, $err) = @_; my $error = qq/Couldn't render template "$err"/; $c->log->error($error); $c->error($error); return 0; } sub render { my ($self, $c, $template, $args) = @_; $c->log->debug(qq/Rendering template "$template"/) if $c && $c->debug; my $output; my $vars = { (ref $args eq 'HASH' ? %$args : %{ $c->stash() }), $self->template_vars($c) }; local $self->{include_path} = [ @{ $vars->{additional_template_paths} }, @{ $self->{include_path} } ] if ref $vars->{additional_template_paths}; unless ( $self->template->process( $template, $vars, \$output ) ) { if (exists $self->{render_die}) { die $self->template->error if $self->{render_die}; return $self->template->error; } $c->log->debug('The Catalyst::View::TT render() method will start dying on error in a future release. Unless you are calling the render() method manually, you probably want the new behaviour, so set render_die => 1 in config for ' . blessed($self) . '. If you wish to continue to return the exception rather than throwing it, add render_die => 0 to your config.') if $c && $c->debug; return $self->template->error; } return $output; } sub template_vars { my ( $self, $c ) = @_; return () unless $c; my $cvar = $self->config->{CATALYST_VAR}; my %vars = defined $cvar ? ( $cvar => $c ) : ( c => $c, base => $c->req->base, name => $c->config->{name} ); if ($self->expose_methods) { my $meta = $self->meta; foreach my $method_name (@{$self->expose_methods}) { my $method = $meta->find_method_by_name( $method_name ); unless ($method) { Catalyst::Exception->throw( "$method_name not found in TT view" ); } my $method_body = $method->body; my $weak_ctx = $c; weaken $weak_ctx; my $sub = sub { $self->$method_body($weak_ctx, @_); }; $vars{$method_name} = $sub; } } return %vars; } 1; __END__ =head1 DESCRIPTION This is the Catalyst view class for the L