[Catalyst] Catalyst, ExtJS and TT
Dave Howorth
dhoworth at mrc-lmb.cam.ac.uk
Mon Mar 18 10:56:30 GMT 2013
Jean-Marc Choulet wrote:
> Hello,
>
> I have a javascript file named EntrepriseWindow.js in root dir. It
> contains some TT code. I must add a extension (I renamed the file
> EntrepriseWindow.js) for it to work. Otherwise, it does not work :
>
> sub EntrepriseWindow :Path('EntrepriseWindow.js') {
>
> my ($self, $c) = @_;
>
> $c->stash->{template} = 'EntrepriseWindow.js.tt';
>
> $c->response->content_type('application/javascript');
>
> }
>
> I cannot write this ?
>
> $c->stash->{template} = 'EntrepriseWindow.js';
Most frameworks that use TT have a mechanism to find template source
files based on their extension. In the case of Catalyst, see
http://search.cpan.org/~jjnapiork/Catalyst-View-TT-0.41/lib/Catalyst/View/TT.pm#TEMPLATE_EXTENSION
If you think about it, the file you want TT to process is *not* a .js
file, it's a file with some TT syntax in it that needs processing to
*become* a .js file. So it would be unhelpful if Catalyst tried to
TT-process real .js files and it's reasonable, IMHO, to have something
like a .js.tt extension.
More information about the Catalyst
mailing list