问题
I understand how I can serve Html pages through Node.js to a client. Now I'm looking for a way to programatically generate Html on the server side (and then do whatever I want with it: save to a file, send to a client). Similiar to the way you'd do the same on the client side, with methods such as document.createElement
or jQuery.
How can programatic Html generation be done with Node.js? (And I don't mean hardcoded Html writing to a file, of course).
回答1:
I think for your purpose reactjs might be the library to look at. It creates a virtual DOM node which is stateful and changes only on statechanges.
for serverside rendering this might be perfect for you! ;)
来源:https://stackoverflow.com/questions/28023829/how-can-i-dynamically-generate-html-content-with-node-js