— Ohhh man this is confusing, too many branches
Don't have cached doc: -> Is it a file? Y: Get via XHR, return the XHR Promise resolved to inserted templates. N: Get via DOM, return inserted templates.Do have cached doc: -> Is it a file? Y: Return a new (non XHR) Promise resolved to inserted templates. N: Return inserted templates.
— So far that's 4 branches which all look completely different
— Why do you need a promise for cached doc?
— Well, it's the expected behavior of loadTemplateXhr and loadTemplateAsync
— I see
— So whether or not it's cached shouldn't change the return value
— Promise.resolve(<value-or-promise>) returns a promise
— Can you push? I'd like to read some of your code
— I will push in a bit, but here's the mess
— Changed a bit, edited link