Question

Let's say I have

Page1.hamlet Page1.julius Page1.lucius

  • Page2.hamlet
  • Page2.julius
  • Page2.lucius

Initially I had those JS files that I would like to convert to .julius

  • Alert.js
  • Page1.js
  • Page2.js

Normaly i would C/P Page1.js and Page2.js directly in the right .julius file. Which is fine by me. But i also need to somehow include another julius that would contain Alert.js so that i do not have to duplicate the code from Alert.js in Page1.julius and Page2.julius

I can't seem to find anything anywhere about that kind of usage. We could say that I am looking for this :

<script type="text/javascript" src="../js/page.js"></script>

In yesod/haskell format

Was it helpful?

Solution

You can add common javascript to a page using the addScriptRemote function in the handler.... For instance, this would add jquery to your webpage.

addScriptRemote "https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"

(of course in your case you would need to host the script locally).

For more details see this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top