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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -