Skip Menu |

This queue is for tickets about the CGI-Application-Plugin-HTDot CPAN distribution.

Report information
The Basics
Id: 17732
Status: resolved
Priority: 0/
Queue: CGI-Application-Plugin-HTDot

People
Owner: Nobody in particular
Requestors: mark [...] summersault.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.03
Fixed in: (no value)



Subject: PATCH: bring load_tmpl() up to date to match CGI::Application
The attached patch was previously submitted directly to the maintainer in November. I'm publishing it here now as official record, in case other people are interested before an official release as made. Primarily it brings the code up to date to be in sync with the current load_tmpl() functionality of CGI::Application. It also adds a default "c" parameter to correspond to the current CGI::Application object. Since I developed the patch, I've realized there may be a problem with this syntax in persistent environments, because a circular reference is created with the CGI::Application object refering to itself. The system I noticed what that CGI::Session quit working properly because the DESTROY {} method for those objects wasn't going out of scope and being called when expected. So I /don't/ recommend adding that part of the patch just yet, although I would really, really like to find a way to provide the same syntax. My personal workaround was leave the syntax in place, but always call flush() explicitly on the CGI::Session object. However, addressing the root issue would obviously be better! Mark
Subject: cap-htdot.patch
Fri Nov 11 22:01:02 EST 2005 Mark Stosberg <mark@summersault.com> * Update load_tmpl to match C::A 4.04 and support default "c" object like TT plugin. diff -rN -u old-CGI-Application-Plugin-HTDot-0.03/Changes new-CGI-Application-Plugin-HTDot-0.03/Changes --- old-CGI-Application-Plugin-HTDot-0.03/Changes 2005-11-11 22:02:40.000000000 -0500 +++ new-CGI-Application-Plugin-HTDot-0.03/Changes 2005-11-11 21:26:39.000000000 -0500 @@ -1,11 +1,15 @@ Revision history for CGI-Application-Plugin-HTDot + - Update load_tmpl() functionality to match how CGI::App 4.04 works (Mark Stosberg) + - Add "c" key to templates by default to allow access to template object. Thanks to + the TT plugin for the inspiration and documenation for this. (Mark Stosberg). + 0.03 2005/08/18 - Added module dependencies to Build.PL. Updated acknowledgements. + - Added module dependencies to Build.PL. Updated acknowledgments. 0.02 2005/08/16 - First public version, released on an unsuspecting world. Mwahaha! ;) + - First public version, released on an unsuspecting world. Mwahaha! ;) -0.01 Never released :( - For my own testing purposes. +0.01 Never released + - For my own testing purposes. diff -rN -u old-CGI-Application-Plugin-HTDot-0.03/lib/CGI/Application/Plugin/HTDot.pm new-CGI-Application-Plugin-HTDot-0.03/lib/CGI/Application/Plugin/HTDot.pm --- old-CGI-Application-Plugin-HTDot-0.03/lib/CGI/Application/Plugin/HTDot.pm 2005-11-11 22:02:40.000000000 -0500 +++ new-CGI-Application-Plugin-HTDot-0.03/lib/CGI/Application/Plugin/HTDot.pm 2005-11-11 21:59:55.000000000 -0500 @@ -82,7 +82,7 @@ my $self = shift; my ($tmpl_file, @extra_params) = @_; - # Add tmpl_path to path array if one is set, otherwise add a path arg + # add tmpl_path to path array if one is set, otherwise add a path arg if (my $tmpl_path = $self->tmpl_path) { my @tmpl_paths = (ref $tmpl_path eq 'ARRAY') ? @$tmpl_path : $tmpl_path; my $found = 0; diff -rN -u old-CGI-Application-Plugin-HTDot-0.03/t/01-load_tmpl.t new-CGI-Application-Plugin-HTDot-0.03/t/01-load_tmpl.t --- old-CGI-Application-Plugin-HTDot-0.03/t/01-load_tmpl.t 2005-11-11 22:02:40.000000000 -0500 +++ new-CGI-Application-Plugin-HTDot-0.03/t/01-load_tmpl.t 2005-11-11 21:59:29.000000000 -0500 @@ -1,25 +1,28 @@ #!perl -T +package TestApp; use strict; use warnings; -use Test::More tests => 4; +use Test::More qw/no_plan/; use Test::Exception; - -BEGIN{ use_ok('CGI::Application'); } - -# bring in testing hierarchy -use lib './test'; -use TestApp; +use base ("CGI::Application::Plugin::HTDot", "CGI::Application"); $ENV{CGI_APP_RETURN_ONLY} = 1; -LOAD_TMPL_TESTING: -{ my $app = TestApp->new( TMPL_PATH => [ qw(test/templates) ]); + $app->param('c_test','Working'); ok(my $tmpl = $app->load_tmpl('test.tmpl'), "Created new page template"); isa_ok($tmpl, "HTML::Template::Pluggable"); + { + $tmpl->param('test','basic tmpl_var test'); + like($tmpl->output,qr/basic tmpl_var test/, "basic tmpl_var is working"); + } + + { + like($tmpl->output,qr/Working/, "c dot notation is working"); + } + # Make sure setting a bad <tmpl_var> dies dies_ok { $tmpl->param( invalid => "BLAH" ) } "Died when setting invalid <tmpl_var>"; -} diff -rN -u old-CGI-Application-Plugin-HTDot-0.03/test/TestApp.pm new-CGI-Application-Plugin-HTDot-0.03/test/TestApp.pm --- old-CGI-Application-Plugin-HTDot-0.03/test/TestApp.pm 2005-11-11 22:02:40.000000000 -0500 +++ new-CGI-Application-Plugin-HTDot-0.03/test/TestApp.pm 1969-12-31 19:00:00.000000000 -0500 @@ -1,13 +0,0 @@ -package TestApp; - -use strict; - -#-------------------------------------------------- -# use CGI::Application; -# use CGI::Application::Plugin::HTDot; -# @TestApp::ISA = qw(CGI::Application::Plugin::HTDot CGI::Application); -#-------------------------------------------------- - -use base ("CGI::Application::Plugin::HTDot", "CGI::Application"); -1; - diff -rN -u old-CGI-Application-Plugin-HTDot-0.03/test/templates/test.tmpl new-CGI-Application-Plugin-HTDot-0.03/test/templates/test.tmpl --- old-CGI-Application-Plugin-HTDot-0.03/test/templates/test.tmpl 2005-11-11 22:02:40.000000000 -0500 +++ new-CGI-Application-Plugin-HTDot-0.03/test/templates/test.tmpl 2005-11-11 21:33:24.000000000 -0500 @@ -1,2 +1,3 @@ <tmpl_var test> +<tmpl_var c.param('c_test')>
This is resolved in version 0.04 and beyond. For whatever reason I never could get your patch to work my local revision, but the changes were easy enough to implement. CAP::HTDot features now match stock CGI::Application (and have tests to match). The parameter c is now passed to all templates....