Here is a snippet from my index.jade file:
script(type="text/javascript")
if user
| window.user = !{user};
else
| window.user = 'null';
if category
| window.category = !{category};
else
| window.category = 'null';
if postid
| window.postid = !{postid};
else
| window.postid = 'null';
script(src="all.js")
After testing, I noticed that the variables user, category, and postid are correctly passed to Jade. However, upon rendering, an error occurs:
Uncaught SyntaxError: Unexpected token <
This error points to the beginning of the file, and strangely, the value of window.postid becomes "all.js". It seems like something is going wrong here. While the category and postid parameters are set using URL parameters, the website operates smoothly when no category or postid is specified ('/') or only the category is provided ('/:category'). Nonetheless, when both the category and postid are passed in ('/:category/:postid'), even though the postid data is properly sent to Jade, assigning this value to window.postid seems impossible without it being overwritten by the src value of the subsequent script tag.