Generate HTML or load it in nodejs world?
I'm new to the nodejs world, a noob question for you: We use haml, ejs, ... to generate HTML files. Can we load our own HTML file like normal? Which way is more e开发者_C百科fficienct?
Note: I think I'm asking a bad question here but it's the way to understand things clearly :)
Most node.js web framework also couple as web servers and are capable of serving plain static HTML files.
Grasshopper is a framework I wrote which handles this. There are even dedicated static file servers for node.js like Paperboy.
If you are serving a plain static HTML page, then you should go with loading the HTML files directly.
but if you are creating dynamic pages, whose content depends on some business logic, then you should use template engines like pub, ejs, haml. most of the web frameworks allow the content to be served from plain HTML files as well as template engines.
精彩评论