[Catalyst] javascript in Catalyst using Template Toolkit

Matt S Trout dbix-class at trout.me.uk
Fri Dec 21 18:51:18 GMT 2007


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 :)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list