Skip to content

Comment on Twitter releases new JS template engine: hogan.js

Comments

Could someone perhaps help me out re: the difference between Compiling and Rendering JS templates? What it feels like is this:

Compiling a JS template on the server gives you a template object that has a render() method. On the client side, you create an instance of the object and pass its render() method a context? Am I missing anything?

If anything, this looks like what I've been looking for to get my templates off my page and into a separate JS file. Makes things cleaner. And apparently faster?

It's usually two separate steps anyway. Populating HTML via the object passed in _while_ parsing is a sloppy way to go about it. This lib (and most template engines) compile down to an executable Function, that you then pass this object to. This means you can re-invoke it several times with less overhead

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.