pzuraq / ember-simple-set-helper

MIT License
12 stars 4 forks source link

Transform to -simple-set #13

Open jrjohnson opened 4 years ago

jrjohnson commented 4 years ago

This allows the template transform to be applied twice (as it may be in an embroider build) because it now a pure function. All instances of set will be transformed so -simple-set so a second pass over the same template will not attempt to transform set again.

This is the solution suggested by @e4f in https://github.com/embroider-build/embroider/issues/403#issuecomment-663906649 and should fix that issue.

I left the original set helper alone and re-exported it as -simple-set because, while it isn't documented I'm not certain there isn't a way to get to this helper directly by doing something like (fn (set this 'foo') 'bar)'. Though I don't think that would actually work, I do think it may have slipped through the if (node.params.length > 2) { assertion in the template transform and could do something that accidentally works in an app.

If I'm wrong about that it would make the most sense to just remove app/helpers/set.js. If this (or some other method) would work to access the existing {{set}} helper directly without a transform then it probably needs a deprecation warning. I'm happy to make either of those changes, but I'd appreciate another set of eyes to tell me which is the right path.