I would like to insert a tag to a specific script into a specific view and nowhere else. This question very nearly captures my problem, but I want to use a script that I have written and wish to put into my public directory on the client side, rather than implementing a script tag with an hfref to an http address elsewhere. I see how the given solution allows you to put a script tag with a unique href in a a specific view, but I don't know where to store the js that I want to insert into the view so that it will be an available asset. I thought at first that any directory I placed inside of '/assets' would be placed inside the public directory on the client-side, but when I tried adding a '/assets/localScripts' directory and placing my script inside it, neither the directory, nor the script showed up. So I thought I'd put the local script inside the 'assets/js' directory, but everything I put in there (even if it's in a sub-directory) is getting added to every view and I don't want this script to be injected into the homepage (or anywhere accept one specific view).
I looked at the pipeline.js file in an attempt to modify the grunt tasks. This resolved question on excluding files from grunt tasks suggests that I should be able to tell grunt to ignore the file '/assets/js/localScripts/gameview.js', but I have had no luck. I tried adding to the end of the part of pipeline that selects js files to inject each of the following exceptions (to do the same thing):
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js',
//My attempted exceptions:
//I think this should ignore anything in the localScripts directory
!'**/localScripts/**',
//I think this should ignore any file named gameview.js
!'**/gameview.js',
//I think this should ignore '/assets/js/localScripts/gameview.js'
!'/assets/js/localScripts/gameview.js'
];
None of these exceptions worked (the script was injected into every page in each case). Am I on the right track? How can I make a js file available to views that have a script tag injected for it, but abstain from automatically injecting every view with a script tag for the file?