Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Catalyst-View-Xslate CPAN distribution.

Report information
The Basics
Id: 70497
Status: open
Priority: 0/
Queue: Catalyst-View-Xslate

People
Owner: Nobody in particular
Requestors: rod.taylor [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.00012
Fixed in: (no value)



Subject: Improve ease of use
There are a few things which both Catalyst::View::TT and Catalyst::View::TT::Alloy do which make things easy. First is using the Catalyst configuration mechanism. This allows me to easily have a different configuration in one or more development environments and production. Particularly important for the cache_dir parameter. To set the ::TT and ::TT::Alloy equivalent of INCLUDE_PATHS[] I find myself doing this: before _build_xslate => sub { my ( $self, $c ) = @_; $self->log->error('START'); my $path = $self->path || []; push( @{$path}, $c->path_to('root') ); push( @{$path}, $c->path_to( q{..}, 'SK', 'root' ) ); $self->path($path); $self->log->error('END'); return; }; To configure a different cache_dir in production and development environments, I find myself manually setting a configuration variable and setting $self->cache_dir() in a similar function. Another useful helper function with be something that prepares a set of Template Toolkit plugins for use. This bit of code in my Xslate view takes a set of plugins string names, loads them during the first templating call, caches the instances of them for future calls, and injects them into the namespace. Quite useful as a TT2 compatibility item. Again, would be nice if I could simply define a 'TT::Xslate' => {PLUGIN => ['Plugin1', 'Plugin2']} section within my standard Catalyst yml file without writing code in my extension of View::Xslate. has plugins => (is => 'rw', isa => 'ArrayRef[Str]', default => sub {[qw{Template::Plugin::Date}]}); has plugin_cache => (is => 'rw', isa => 'HashRef[Template::Plugin]', lazy_build => 1); sub _build_plugin_cache { my ( $self ) = @_; $self->log->error('START'); my %plugins; for my $plug (@{$self->plugins}) { my $varName; if ($plug =~ m/([^:]+)$/) { $varName = $1; } Class::MOP::load_class($plug); $plugins{$varName} = $plug->new(); } $self->log->error('END'); return \%plugins; } before render => sub { my ( $self, $c ) = @_; $self->log->error('START'); # Merge plugin namespace $c->stash(%{$self->plugin_cache}); $self->log->error('END'); return; };
thanks for the report, however I'm not getting it. Show quoted text
> To set the ::TT and ::TT::Alloy equivalent of INCLUDE_PATHS[] I find
...which is "path" in Xslate, so you should be able to do something equivalent to the following in your catalyst config, no? View::Xslate: path: - path_to("foo") - path_to("bar") If that's not the case, I'm clearly not seeing your prerequisites, so please start from the very beginning. Show quoted text
> Another useful helper function with be something that prepares a set of > Template Toolkit plugins for use.
<snip> I understand the use case, but that would be sort of like saying "V::Xslate should be used in TTerse mode" Maybe there's another approach. I haven't thought much about it so I may be just way off, but perhaps include a V::Xslate::TTerse that has plugins() attribute?
From: rod.taylor [...] gmail.com
On Thu Aug 25 23:48:33 2011, DMAKI wrote: Show quoted text
> thanks for the report, > however I'm not getting it. >
> > To set the ::TT and ::TT::Alloy equivalent of INCLUDE_PATHS[] I find
> > ...which is "path" in Xslate, so you should be able to do something > equivalent to the following > in your catalyst config, no? > > View::Xslate: > path: > - path_to("foo") > - path_to("bar")
Ahh, sorry. I tried a few variations of config changes and was unable to get them to be picked up so I assumed using Catalyst Config was not supported. If Catalyst should be setting the variables itself then I need to figure out what I am doing wrong. Sorry for bothering you. Please close this report.