I would like to run JSHint on all my Javascript source files but several of them have some embedded Django template markup. JSHint throws a ton of errors on this markup.
Is there a way to either…
- Tell JSHint to ignore this markup
- Run the Djnago template parser with some dummy data to generate all permutations of the rendered js file and then run JSHint on that?
I assume I could write a bunch of code to do #2 but i’m wondering if there’s an easier way.
Depending on a markup you can get away with “hiding” Django markup with JavaScript comments. We do this, for example:
The only thing is that you have start script.js with a blank line—otherwise
//will eat the first legitimate line of JavaScript code you have there. I wrote a simple helper{% includejs %}that does that for me automatically.