Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node and HTML together, is possible?

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.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node and HTML together, is possible?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×