Reputation: 607
So I have never used turbogears before but the company I am interning at has turbogears to run their JS files. I am trying to integrate my new JS code into their files but running into repeated errors just calling the scripts and was wondering if anyone had any experience with this.
The code so far
<script type="text/javascript" data-main="${tg.url('/pv/demo.js')}" src="${tg.url('/pv/js/require.js')}"></script>
So I know it finds the require JS file with the $(tg.url()) command but I am experiencing issues with it calling other JS files in the pv directory. Getting a red GET and failure to load resource in my console.
Idea (terrible one)
If I call each script in the html file using the turgogears command which would honestly take some time since there are around 20 files. It wouldn't look as clean too.
Question
Is there a way to run that command on all the files or make it work with require.js different from what I had before?
UPDATE
Hey so in require js we have the command
requirejs.config({
'baseUrl': 'src',
});
Which well tell the html page to load up all the JS files in the src file first. But if I need to run turbogears in the HTML page for it to fetch files how would I go about doing that? I did try to copy and paste the command of
${tg.url('/pv/src')}
but that sure as hell didn't work. Any suggestions ?
Upvotes: 0
Views: 120
Reputation: 1791
tg.url
just returns the string of url, so there is usually no difference between writing /py/demo.js
and ${tg.url('/pv/demo.js')}
.
What tg.url
will do for you is to compensate for SCRIPT_NAME
in case your application is running on a subpath, but when developing locally through gearbox
or when deploying on the root of a virtual host you shouldn't notice any difference in the generated urls.
Can you try to better express your problem? It seems to me it might be more related to requirejs than to turbogears itself and you might need to set requirejs baseUrl
( see http://requirejs.org/docs/api.html#config-baseUrl )
Upvotes: 1