Browser Compatibility NodeJS templating

I am looking to reuse the templates that I write for NodeJS in a browser, so I hope to get a quick page load time (initial rendering) and the ability to switch dynamic content, etc.

Would this be most natural on Node, any ideas for compatible template engines?

By the way, I like the HAML style syntax, so anything based on HAML is a huge plus.

Thanks! Roman

Edit: I think I like the Mustache approach the most, it works with Express, and also on the client side .. will be updated here on how the implementation is implemented.

+7
source share
6 answers

Jade is excellent, very similar to HAML and comes down to JavaScript for use by the browser :)

See README at the Github repo for more details.

Jade is also a semi-officially recommended template language for the currently most popular web infrastructure for Node, Express (in fact, they share the authors), so it looks like a solid choice for me.

I recently appreciated many NodeJS template libraries and ended up choosing Jade.

I made a simple example of using Jade in a browser . Fun stuff happens in demo.js , and you can also view index.jade , which contains the main markup page.

+11
source

EJS works in the browser and with express out of the box. Admittedly, the syntax is not a HANL style and is not particularly rich, but you can easily make it work.

I also used a simple technique to reuse templates and views on both the client and server, and it works quite well

+2
source

JAVASCRIPT TEMPLATE SHOWDOWN! ~

These are almost all the best templates built for testing in a browser.

(also @Raynos includes a jade example in the browser)

Personally, I use Jade, in combination with a stylus and jquery. I use only css selector.

But., As can be seen from the graph, Jade does not get along with firefox 3 or opera.

+1
source

You can try to hide https://github.com/hij1nx/weld , which has an implementation on the server side and on the client side.

0
source

node-jqtpl is your best bet. This is the jQuery Templates port, so it is 100% reused in the browser.

0
source

There is a TplCpl utility command written in Node.js that allows you to compile Jade templates for use by the browser.

https://github.com/jsmarkus/tplcpl

0
source

All Articles