Skip to content

Instantly share code, notes, and snippets.

@pbcj
Created May 17, 2011 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbcj/975976 to your computer and use it in GitHub Desktop.
Save pbcj/975976 to your computer and use it in GitHub Desktop.
package Template::Toolkit::Plugin::SubTemplate;
use base 'Template::Toolkit::Plugin';
sub new {
my $config = ref($_[-1]) eq 'HASH' ? pop(@_) : { };
my ($class, $context) = @_;
my $self = bless {
_context => $context,
_session => $context->stash->{_session}
}, $class;
return $self;
}
sub load { # called as MyPlugin->load($context)
my ($class, $context) = @_;
return $class; # returns 'MyPlugin'
}
sub process {
my $self = shift;
my $url = shift;
my $template = WebGUI::Asset->newByUrl( $self->{_session}, $url );
return $template->process( $self->{_context}->stash );
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment