简体   繁体   中英

Express + Jade rendering - client or server side?

I just started using ExpressJS and Jade and I was sure that everything is server-side but this post makes me a little bit confused(because my site behaves like Client-side scenario): https://stackoverflow.com/a/12291675

I guess that node.js only sends whole site once and then sends JSON data, because the rest is loaded in browser cache?

So it would be helpful if someone describe this mechanism to me.

You can code an express.js app to render jade templates into HTML on the server side and send HTML to the browser. This is the more traditional approach. However, jade is also capable of running in the browser, so your express app can send jade templates (either as jade syntax text or pre-compiled javascript function source code) to the browser and also send JSON data to the browser and let the browser render the jade template plus JSON data into HTML to be inserted into the DOM. Both are possible. Neither are prescribed by express or jade. It's your choice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM