linkedin/dustjs-helpers — pull request #64 by mouyang (2014-01-16 19:31:56+00:00)
Title: GH-32 - Use iteration to populate dust.helpers

GH-32 - Instead of overwriting dust.helpers in the module, use iteration to populate the header methods. This should be fine because dustjs <--dependsOn-- dustjs-helpers and dustjs defines a helpers attribute.

* Why you decide to implement this feature.

This seems like a long standing issue that is not immediately obvious from the documentation. I use custom helpers in my private project and I could have encountered this issue - I didn't only because how I set up my dependencies in require.js (custom helpers were in an AMD depending on full dust.js).

* In which cases it will be useful.

Any time helpers get called between dustjs and dustjs-helpers declarations.

The main roadblock seems to be race conditions, so I wanted to force a specific script loading order. I used LABjs to do this on the client, and it was a code rearrangement on the server.

* Side effects

If user defines helpers with the same names defined in dustjs-helpers, the last declaration will win. I have no idea how to handle that beyond namespaces within dust.helpers, or declaring caveat emptor. That seems clunky and that would probably require more widespread code changes.