juliangruber/streamstache — pull request #2 by substack (2014-03-22 06:05:10+00:00)
Title: blocks

Blocks of all kinds! This patch implements blocks for booleans, arrays, and streams.

# boolean blocks

```
{#enabled}
This text appears when `enabled` is truthy.
{/enabled}
```

# array blocks

```
{#critters}
The {name} says {says}.
{/critters}
```

For a `critters` value of:

``` js
[
{ name: 'cow', says: 'moo' },
{ name: 'human', says: 'ho hum' },
{ name: 'rock', says: "«I'm a rock.»" },
]
```

The output expands to be:

```
The cow says moo.
The human says ho hum.
The rock says «I'm a rock.».
```

# stream blocks

Stream blocks are just like array blocks, but the rows (in objectMode) show up asynchronously.

I've tested nested arrays but not nested stream blocks. This patch also doesn't work so cleanly with the existing get/set stuff since I needed nested contexts. Future patches that used an array for the get/set keys could work better with the nested contexts required for blocks.