ractivejs/ractive — pull request #662 by Rich-Harris (2014-05-02 03:14:23+00:00)
Title: Handlebars syntax

Credit for this PR belongs entirely to @marcello3d.

It adds support for Handlebars block syntax - instead of the all purpose `{{#foo}}...{{/foo}}`, it is now possible to do

```html
{{#if foo}}...{{/if}}
{{#each foo}}...{{/each}}
{{#with foo}}...{{/with}}
{{#unless foo}}...{{/unless}}
```

We also now have `{{else}}` blocks:

```html

{{#loggedIn}}
Welcome back!
{{/loggedIn}}

{{^loggedIn}}
Please log in
{{/loggedIn}}

{{#if loggedIn}}
Welcome back!
{{else}}
Please log in
{{/if}}
```

@marcello3d - A few points to note/final details to iron out before this gets merged in:

* I've made `rewriteElse` true by default. I'm not totally averse to having compound if-else blocks, but a) they'd have to be implemented, whereas we can use `rewriteElse`'d blocks today, and b) I think @martypdx made a pretty good case about avoiding unnecessary computation. Any objections?

* I think `{{#try}}` is a pretty interesting idea. But since it's not implemented (at least in this branch) I've removed it for the time being.

* I've made all sections of type SECTION, as discussed, and used `n` to denote the different types.

Let me know if you're good with all this and we can merge it in, start getting some feedback, and iron out any bugs.

It occurred to me that it'd probably make sense to enable handlebars mode by default since it falls back to Mustache. I don't think there's a downside? But for the moment it has to be explicitly enabled.