I’m playing around with Nodejs, and am wondering if I can use jade style shorthand (ie
a(href='/page?name=contact')
as part of an argument passed into a jade file.
Say, for example, that I want to write something along the lines of (from the Ninja Store example):
var name = req.query.name;
var contents = {
about: 'a(href="/page?name=about") Ninja Store \n sells the coolest ninja stuff in the world. Anyone shopping here is cool.',
contact: 'You can contact us at <address><strong>Ninja Store</strong>,<br>1, World Ninja Headquarters,<br>Ninja Avenue,<br>NIN80B7-JP,<br>Nihongo.</address>'
};
res.render('page', { title: 'Ninja Store - ' + name, username: req.session.username, content:contents[name] });
Is there a mechanism I can use to write this style of code?
You’d have to compile the string:
However, you could just switch between views rather than storing them in
contents:Aand, you can still have them contained in
page.jadewith template inheritance.page.jade:
about.jade: