Created
June 27, 2016 10:04
-
-
Save z2015/31b229a856b58dd809bac354f32f494e to your computer and use it in GitHub Desktop.
Sails.js - How to inject a js file to a specific route?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%- blocks.localScripts %> | |
| <% block('localScripts', '<script src="https://maps.googleapis.com/maps/api/js"></script>') %> | |
| // you can add as many as you like | |
| res.locals.scripts = [ | |
| '//maps.googleapis.com/maps/api/js', | |
| ]; | |
| return res.view(); | |
| <!--SCRIPTS--> | |
| <!--SCRIPTS END--> | |
| <!-- Loop through all scripts that passed from controller --> | |
| <% if (scripts) { %> | |
| <% for (i = 0; i < scripts.length; i++) { %> | |
| <script src="<%- scripts[i] %>"></script> | |
| <% } %> | |
| <% } %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment