-
Notifications
You must be signed in to change notification settings - Fork 14
How to include a javascript using javascript include tag
Added for version: 0.4
You can link to javascript files using the javascript-include-tag function in your views.
You will likely only use the javascript-include-tag function in your layouts since the javascript tag should only be in the head tag of your html page.
To include “test.js” use:
(javascript-include-tag "test.js")
You can set attributes on the script tag by passing html-options. To set the charset to “utf-16”:
(javascript-include-tag "test.js" { :charset "utf-16" })
You can include more than one javascript file at once by passing a vector of javascript file names. To include “test1.js”, “test2.js” and “test3.js” use:
(javascript-include-tag ["test1.js", "test2.js", "test3.js"])
You can set attributes for all of the generated javascript tags above by passing an html-options map. To set the charset to “utf-16” for all of the javascript files above use:
(javascript-include-tag ["test1.js", "test2.js", "test3.js"] { :charset "utf-16" })
Conjure comes with a couple of javascript files. Since including them is common, there are two convenience functions:
Include the jquery javascript file:
(jquery-include-tag)
Include the conjure javascript file:
(conjure-js-include-tag)
If you would like to change the names of either included javascript files, you can change their corresponding vars in config/environment.clj.