I have an app in express/nodejs, using jade as template engine.
In a template file there is this the following paragraph
p.btn(onclick='clicked( #{entity._id} )') Click
and after this paragraph (after some tags) there is a script tag in which there is a javascript function.
The problem is that if i click the paragraph it throws
Uncaught SyntaxError: Unexpected token ILLEGAL
in the script tag. If i see in the DOM inspector this script tag it is bad syntax highlighted but it hasn't incorrect syntax.
Furthermore if i delete #{entity._id}
in the onclick attribute of paragraph above it doesn't throw any error.
Why? What are the best practices to write and include script tag in jade template?
EDIT:
generated HTML for the paragraph is
<p onclick="clicked(5025)" class="btn">Click</p>
click handler is in external file (included by script tag) and is
var clicked=function(id){
location.href='/click/'+id+'/';
};
The error is throwed in following script tag (that is some tag after the paragraph)
<script>flowplayer("5025","/javascripts/flowplayer/flowplayer-3.2.12.swf",{
clip:{
autoPlay:false
}
});
</script>