[Catalyst] javascript in Catalyst using Template Toolkit
John Romkey
romkey at apocalypse.org
Sat Dec 22 05:25:11 GMT 2007
On Dec 21, 2007, at 1:51 PM, Matt S Trout wrote:
> On Thu, Dec 20, 2007 at 02:11:50PM -0500, John Romkey wrote:
>> Two recommendations, assuming the Javascript file isn't meant to be
>> modified at runtime:
>>
>> First, use an absolute path to the file in your script tag, ie:
>> <script src='/static/clock.js'> or use $c->uri_for() to compute the
>> path.
>
> An absolute path like that assumes your app will always be deployed
> at /.
>
> My experience is that every time I think I -can- make that
> assumption, later
> I end up really wishing I could deploy my app to a sub-URL for
> testing or
> similar.
>
> You may not have such bad luck, but I don't like to take that chance
> these days :)
I understand, and of course you're right about that. I have had that
bite me once. I was definitely going for the quick fix here.
Since uri_for() won't help with static file paths, is there any
convention for storing the path for static files in the config, or
getting access to it in some other way?
- john romkey
http://www.romkey.com/
More information about the Catalyst
mailing list