xxgreg / mustache

Mustache template Dart library
BSD 2-Clause "Simplified" License
57 stars 59 forks source link

Allow list items to be targeted by index #5

Closed timkendrick closed 10 years ago

timkendrick commented 10 years ago

This allows templates to access list items by index, as discussed in https://github.com/janl/mustache.js/issues/158.

Example usage: {{#myList.0}} {{/myList.0}}

xxgreg commented 10 years ago

Thank you!

I added some tests. Feel free to flesh these out.

https://github.com/xxgreg/mustache/commit/e9c2bb793b9093123afa7d05427096090d639c70

Also - should this throw a RangeError when the index is out of range, what do other mustache implementations do? I find strict is usually better, but mustache libraries often seem to prefer lenient handling of errors.

If you're happy with this let me know, I'll push it up to pub.

timkendrick commented 10 years ago

Great, thanks for adding the tests. I was wondering the same thing about whether to throw a RangeError, feel free to modify the code however you want and push to pub. Thanks!

xxgreg commented 10 years ago

Updated to version 0.1.17 http://pub.dartlang.org/packages/mustache