sintaxi / terraform

Asset pipeline for the Harp Web Server.
102 stars 101 forks source link

Expose lodash to templates #109

Closed lunelson closed 9 years ago

lunelson commented 9 years ago

This PR requires lodash.js and adds it to the locals object passed to templates, for more powerful data manipulation in .jade and .ejs

ir-g commented 9 years ago

+1 for this feature - super useful

kennethormandy commented 9 years ago

Thanks so much for the pull request!

I’m quite fond of this idea still, depending on what @sintaxi thinks. There’s definitely some craziness in some of the boilerplates that could be removed with this, and it’s still possible to avoid using it entirely if you don’t want to commit to making lodash/underscore a dependency for your templates.

I think we’d want to add one or two very basic tests, like we do with Autoprefixer, etc. which basically just check it’s available in the templates as expected.

lunelson commented 9 years ago

Yeah I hope I did it right—it works in my testing—I've done this before with Jade in other implementations, passing lodash in to the globals object, but it seemed to me in your code (which is very clearly structured btw) that the best place was the locals object which also contains public, current etc., so I packed it in there.

lunelson commented 9 years ago

Possibly the package.json should list the lodash version more loosely though, like just 3.x

sintaxi commented 9 years ago

Yep, I like this. Thanks for the PR!