jonschlinkert / expand

Recursively resolve templates in an object, string or array.
MIT License
8 stars 3 forks source link

Return value from render #6

Closed doowb closed 8 years ago

doowb commented 8 years ago

Returns the value from render. Adds test.

The main issue was that if the returned results from a function happened to be a property on the data context, then the value of that property was returned instead of the expected value (from the function).

Let me know if this looks like the correct approach. It might be that we should change this line to:

return resolve(val, data, options);
jonschlinkert commented 8 years ago

maybe we should add a couple more tests with variables passed to the functions, etc. like <%= a(foo) %>

doowb commented 8 years ago

I added a couple more tests last night that test using the data passed in directly and using it in combination with this inside the helper.

I discovered that the interpolation method fails when using this because the context isn't bound to the functions at that point. The code then falls through to the .render method where the context is bound.

jonschlinkert commented 8 years ago

If you're good with it feel free to merge, thanks!