hi there, how do I access the Catalyst variable in a custom made Template Toolkit plugin?
WhaT I have done: read up on http://search.cpan.org/src/MRAMBERG/Catalyst-View-TT-0.27/lib/Catalyst/View/TT.pm For example, I have my own plugin, "package myApp::View::Template::Plugin::User" use strict; use warnings; use base 'Template::Plugin'; use Template::Plugin; use DateTime; use DateTime::Format::Pg; sub load { my ( $class, $context ) = @_; return $class; } sub new { my ( $class, $context, @params ) = @_; bless { _CONTEXT => $context, }, $class; # returns blessed MyPlugin object } sub get_current_user { my ($class, $c) = @_; $c->log->debug( "The type is " . ref ($c)); return $c->session->{'active_user'} ? $c->session->{'active_user'} : $c->user->login_id; } =============== And in my template toolkit, "display_user.tt2" I do something like: [% current_user = User.get_current_user(Catalyst) %] THE current user is ([% current_user %]).... I noticed that myApp::View::Template::Plugin::User->get_current_user doesn't print out any values. I suspect it has not even been able to recognise the Catalyst variable. I even tried doing "[% current_user = User.get_current_user( $Catalyst ) %]" in the display_user.tt2 template file. Please help :) K. akimoto _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
