I've created an app with the express framework, which comes with jade as its templating engine. While playing around with jade, I've set up what I feel to be a simple test:
In Node I am passing an object to the jade template on render res.render('index', { title: 'Express', docs:"is jade cool?"});
, and in the template I'm trying to call the values like so:
h1= title
p Hi!
p Welcome to #{title}
p #{docs}
- console.log(docs)
script(type='text/javascript').
console.log(docs);
What I've found is that I can't console log the global object values, and if I try #{docs}
, it tries to parse it as a literal command rather than the string it started as. I also found that I cannot assign it to a JS var, like this: var test = #{docs};
.
Can someone explain:
- What is the difference between
#{docs}
,!{docs}
anddocs
? (Oddly enough all three examples are used in the documentation, but none of them are really explained.) - What is the correct way to console log the global object properties passed to jade from Node and the correct way to assign those same properties to local JS variables?