patjlm / mustache-ant

A Mustache implementation for ant scripts, based on JMustache
2 stars 1 forks source link

Support for lambdas? #1

Open dagoss opened 8 years ago

dagoss commented 8 years ago

Based on the Mustache(5), mustache is supposed to have support for lambdas. This is also supposed by JMustache.

Lambdas

When the value is a callable object, such as a function or lambda, the object will be invoked and passed the block of text. The text passed is the literal block, unrendered. {{tags}} will not have been expanded - the lambda should do that on its own. In this way you can implement filters or caching.

Template:

{{#wrapped}} {{name}} is awesome. {{/wrapped}}

Hash:

{
   "name": "Willy",
   "wrapped": function() {
        return function(text, render) {
            return "<b>" + render(text) + "</b>"
        }
    }
}

Output:

<b>Willy is awesome.</b>

It seems that mustache-ant does not support this. Is this something that can/should be supported?

patjlm commented 8 years ago

I am not sure how that would look like within ant. Something like a filter?