News for hackers. Stuff that matters.
Re:Mustache 2.0 and the Future of Mustache.js by chubot on Sunday February 13, 2011 @02:51PM (#2213654)
Please look at JSON Template. http://code.google.com/p/json-template/

It solves ALL of these problems. It has {.or}, the dot notation, and searches up the stack of contexts for variables.

I haven't been working on it for awhile, mostly because it does the job, but the codebase is small and easily hackable.

EDIT: It also compiles the templates and lets you change the delimiters! And has support for several other languages.

Re:Mustache 2.0 and the Future of Mustache.js by janl on Sunday February 13, 2011 @03:31PM (#2213802)
JSON Template was around before mustache came around, it didn't win then, I don't know if it will win now. I want to improve the Mustache line, not make people switch to something else.

As an alternative, it looks good, so thanks for bringing it up.

Re:Mustache 2.0 and the Future of Mustache.js by chubot on Sunday February 13, 2011 @11:51PM (#2215313)
I don't really think of it as "winning or losing". It's not like a general purpose programming language with large network effects (e.g. you may depend on a library with 100k sloc). The switching cost is pretty low, especially since they both use JSON as the data model.
Re:Mustache 2.0 and the Future of Mustache.js by arnorhs on Sunday February 13, 2011 @07:46PM (#2214706)
JSON template looks nice. Great feature set.

I don't know about the python version, but I had a look at the Javascript code for json-template. At first look it seems pretty "hacky". The main obvious flaws I saw were:

- it's polluting the global namespace a lot. Introducing a lot of functions and variables. - it's roughly 800 lines, while mustache.js is just over 300. I realize json template has more features. - A lot of the javascript could do with some optimization. Especially some of the loops.

But maybe that's something you simply want help with?

Re:Mustache 2.0 and the Future of Mustache.js by chubot on Sunday February 13, 2011 @11:40PM (#2215288)
Everything is wrapped in the "jsontemplate" namespace. It's just not indented.

If you have some speedups I'm open to it, although I think it is pretty fast as it doesn't parse the template on every expansion.

Re:Mustache 2.0 and the Future of Mustache.js by binspace on Sunday February 13, 2011 @05:13PM (#2214136)
Mustache has an equivalent to {.or}

{{^something}} {{/something}}

The draw of mustache is that it does things implicitly. I don't have to worry about .section, .repeated, .or, |html, for example. Mustache does it for me.

That being said, one thing that mustache does need to address is the difference between conditionals and repeated operations as needed (handled by .section and .repeated in JSON Template).

AFAIK, the songs template would require a boolean to be passed in of the existence of songs in mustache, since mustache would implicitly assume that {{#songs}} was a loop and create multiple tables.

http://json-template.googlecode.com/svn/trunk/doc/Introducin...

Re:Mustache 2.0 and the Future of Mustache.js by janl on Sunday February 13, 2011 @05:27PM (#2214188)
If you read the linked article, you'd see that I am calling for an {.or}-like construct to avoid having to use inverted sections for a fake else-case.
Re:Mustache 2.0 and the Future of Mustache.js by binspace on Sunday February 13, 2011 @05:36PM (#2214222)
Got it. I guess the distinction is not that big of a deal for me, though it would be nice to have the inline {.or}-like construct (it saves one statement).
Re:Mustache 2.0 and the Future of Mustache.js by chubot on Sunday February 13, 2011 @11:55PM (#2215324)
You can set the default formatter to "html" if you want (or any other formatter). It probably could be better documented.

You seem to be on the fence about if you want an explicit "repeated" or not. I haven't thought about it too much but it seems cleaner to be explicit. I don't want to confuse an object {} and a singleton array [{}].