node.js - How to get username injected into html? -
i have static html site:
index.html
i want use handlebars {{username}} inject username variable. looks like:
res.render('index', {username:'myname'})
should work. problem index.html in '/static' (my express.static()) directory. best way username variable html page without having convert doesn't html? thats why dont want use jade , prefer handlebars. if there other way, best.
update: preserve same structure have (keeping in static directory) opposed moving things out "views" directory. possible?
then must have use template engine. can use jade support html, have use .
@ end of tag like:
doctype 5 html. // dot <body> <div>this jade testing html</div> </body>
is there way keep file in /static directory without having put in "views" directory?
yes can use _dirname
while rendering
app.get('/anyurl/' , function(req, res){ res.render(__dirname + '/../static/path/folder') //modify path according structure });
Comments
Post a Comment