xxgreg / mustache

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

Handlebars helpers #16

Open xxgreg opened 9 years ago

xxgreg commented 9 years ago

Add a simple version of helpers as implemented in handlebars.js.

http://handlebarsjs.com/

var t = new Template(
                     '{{ uppercase foo }}',
                     helpers: {'uppercase': (ctx) => ctx.arguments[0].toUppercase()});

 t.render({'foo': 'bar'}); // outputs 'BAR'

These can also be used with sections.

Initial hacky implementation here:

https://github.com/xxgreg/mustache/tree/handlebars-helpers

MikeMitterer commented 9 years ago

:thumbsup:

xxgreg commented 9 years ago

I'm unfortunately busy with other things at the moment. But I recently rewrote the parser to make it easier to implement helpers. Have a crack at this if you are interested - I'm happy to help with reviews.