async helpers (refactor, externalize, and improve!!!)
@jonschlinkert and I have talked about this and I've been looking through the current modules that have touch points to async helpers and trying some things out to try to improve the experience with some of the use cases that we've come across.
I think that the following steps can be taken to refactor and externalize some of the current pieces, while creating a couple new pieces for so cases:
-
[ ] refactor async-helpers
- [x] better readability (aleady started by @jonschlinkert)
- [ ] implement promises
-
[ ] remove async-helpers from engine-cache
- the only real touch points in engine-cache are adding helpers to the
asyncHelpersinstance when compiling, and resolving async helper ids after the string has been rendered - moving this out of engine-cache makes way for the next step
- the only real touch points in engine-cache are adding helpers to the
-
[ ]
base-async-helpersmodule that adds the async-helpers functionality tobaseapplications- [ ] move
asyncHelper,asyncHelpers,getAsyncHelper, andhasAsyncHelpermethods frombase-helpersto `base-async-helpers - [ ] wrap
engine-cachemethods to inject theasync-helpersfunctionality into.compileand.render(this can be more configurable and only enabled for specific engines)
- [ ] move
-
[ ] Make built-in
singularandpluralhelpers "smarter" to know if they're being used as async or sync helpers. Either split them out into a module or just check for the callback. -
[ ]
base-handlebars-async-helpersmodule to add necessary helpers and batch methods in Handlebars to allow using async-helpers with built in Handlebars partial syntax.- I've done this in an example and tried to implement it directly in
engine-handlebars, butengine-handlebarsis not able to get a reference to theasyncHelpersinstance created byengine-cache. - I think splitting out the other pieces and adding this functionality as a plugin will let users choose when they're going to use async-helpers and if they'r using Handlebars, they can also include this module to fix some specific use cases.
- Since we include
engine-handlebarsinassembleby default, we can include this also (or have an option to enable async-helpers which would then includebase-async-helpersandbase-handlebars-async-helpers)
- I've done this in an example and tried to implement it directly in
-
[ ] optional
base-engine-async-helpersmodule that will do something withengine-baseto get async-helpers to work with regular javascript conditional statements (I don't know exactly how to do this yet, but we've thrown around a few ideas)
I'll be working on these changes over the next few days. Feedback is welcome and encouraged!
deleted a comment that wasn't related to this thread