Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Feature/loop syntax #23

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

wesen commented Jul 19, 2011

Out of the same clarity/optimization needs, I decided to use {{, }} to iterate (and only iterate) over an array (or a hash depending on the language), rather than the "i can do everything" {{#section}}.

let me know what you think

+ b: 2
+ c: 3
+ template: '{{,array}}{{a}} {{/array}}'
+ expected: 'first first first '
@urzds

urzds Feb 1, 2017

This test looks exactly like the previous one. Where is the difference?

urzds commented Feb 1, 2017

I also support this request, as I would like to iterate over a hash (key/value pairs). Could you please add an example of how that would look like? I propose {{,hash}}key: {{key}}, value: {{value.nstd.idx}}{{/hash}}

Using comma , as the "keyword" seems a bit unintuitive, but other than * I also have no good idea what else to use.

@urzds urzds added a commit to urzds/lustache that referenced this pull request Feb 1, 2017

@urzds urzds Support explicit iteration over arrays and maps using a new '*' tag
Explicit iteration blocks are e.g. necessary to support iteration over
 maps/hashes, as in the following example:

```mustache
Key/value pairs:
{{*hashmap}}
  - {{key}} = {{value}}
{{/hashmap}}
```

I did not include tests, because their data is included in the corresponding
 pull request to the Mustache spec.

See-Also: mustache/spec#23
f717f2e

@urzds urzds added a commit to urzds/lustache that referenced this pull request Feb 1, 2017

@urzds urzds Support explicit iteration over arrays and maps
Explicit iteration blocks are e.g. necessary to support iteration over
 maps/hashes, as in the following example:

```mustache
Key/value pairs:
{{*hashmap}}
  - {{key}} = {{value}}
{{/hashmap}}
```

I did not include tests, because their data is included in the corresponding
 pull request to the Mustache spec.

See-Also: mustache/spec#23
b719c4f

@urzds urzds referenced this pull request in Olivine-Labs/lustache Feb 1, 2017

Open

Support explicit iteration over arrays and maps #28

@urzds urzds added a commit to urzds/lustache that referenced this pull request Feb 1, 2017

@urzds urzds Support explicit iteration over arrays and maps
Explicit iteration blocks are e.g. necessary to support iteration over
 maps/hashes, as in the following example:

```mustache
Key/value pairs:
{{*hashmap}}
  - {{k}} = {{v}}
{{/hashmap}}
```

I did not include tests, because their data is included in the corresponding
 pull request to the Mustache spec.

See-Also: mustache/spec#23
8273752

@urzds urzds added a commit to urzds/lustache that referenced this pull request Feb 1, 2017

@urzds urzds Support explicit iteration over arrays and maps
Explicit iteration blocks are e.g. necessary to support iteration over
 maps/hashes, as in the following example:

```mustache
Key/value pairs:
{{*hashmap}}
  - {{k}} = {{v}}
{{/hashmap}}
```

I did not include tests, because their data is included in the corresponding
 pull request to the Mustache spec.

See-Also: mustache/spec#23
10262a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment