Skip to content

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

Comments

Thanks for a detailed response. I checked out the link and saw Mustache in the source. I still dont see (if im correct in thinking) how this de-duplicates effort?

They still have to do the work to construct the JSON, no?

PS. Not trying to be inflammatory, i'm just trying to understand this better but struggling to get my head around it. I just watched a templating video by the YUI team for Node.js and am still none the wiser. :(

It really decouples the model (the data that's served in the json) from the view (the mustache template). This lets frameworks like ember and backbone do MVC on the client side where the server is really just there to serve up a model (in the same way that a database does for most current apps).

Making an http request is then equivalent to making a sql query.

I've been working with Backbone and mustache and unfortunately I have to munge my models a lot to get the right results - like passing the cid or converting dates, etc. How do you work around this? I have thought of initializing many of these, but then I'd need to bind on changes... I guess you could save lambdas as attributes?

Probably closer to a stored procedure or prepared statement :)

Yeah, you'll still need to jump through some hoops to get the data ready. Templates are useful when you have a JSON data source and a rather complex HTML UI that is built off the data on the fly after the page loads. You could totally build the HTML manually inside Javascript as well, but it gets time consuming for the developer, especially with Javascript's lack of long-format strings """like these in Python""".

Thanks for the detailed responses all. Im starting to understand this a little better ;-)

AboutSource Built by g1lg1l

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