Node and HTML together, is possible?
Problem
Currently or futurely, is possible merge Html and Node on same file, like PHP does? Currently I know that we need use a template file or util.print()
, but for very simple cases, exists other solution, like ... ?
Hello !
Return:
Hello World!
Problem courtesy of: David Rodrigues
Solution
Node.js itself does not support this out of the box, but there are several frameworks (including the popular Express.js) that do. Look for "templates" for Express.js and you'll see several options to do this including EJS (embedded JavaScript) and Jade.
http://expressjs.com/guide.html
Solution courtesy of: Hector Correa
Discussion
View additional discussion.