[Catalyst] external javascript files
Ashley
apv at sedition.com
Mon Mar 24 21:58:18 GMT 2008
On Mar 24, 2008, at 2:43 PM, Jennifer Ahn wrote:
> i'm tyring to call my external javascript library under myapp/root/
> src/myjavascript.js in my tt2 file by placing this line at the top
> of the tt2 file:
> <script language="Javascript" src="/myjavascript.js" type="text/
> javascript"></script>
The language attribute is, IIRC, deprecated in all current X?HTML.
It's best to use uri_for() with pretty much everything. It lets you
do your app in a number of different ways while resolving resources
correctly. So–
<script src="[% c.uri_for("/myjavascript.js") %]" type="text/
javascript"></script>
>
I have also started to make URIs relative this way when possible/
allowed–
<script src="[% c.uri_for("/myjavascript.js").path %]" type="text/
javascript"></script>
>
It's best to setup your server to serve this kind of resource instead
of your app if/when you can. Check the advent calendars and tutorial
docs for examples of that. You'll probably want your js files in your
static path to make this easier.
-Ashley
More information about the Catalyst
mailing list