mustache / spec

The Mustache spec.
MIT License
368 stars 71 forks source link

Clarification on functions as context #39

Closed thegrandpoobah closed 12 months ago

thegrandpoobah commented 12 years ago

According to the spec (from the section YAML, not mentioned in interpolation YAML):

5) Otherwise, the data is the value returned by calling the method with the given name.

So the following invocation:

Mustache.render('{{foo}}', { foo: function() { return null; } });

Would render out as (at least in JavaScript anyways) null the way I am interpreting the spec. But that seems a little on the sub-optimal side. Did I mis-interpret the sepc or is this another one of those language dependent traps?

Thanks for the clarification.