-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make loader aware of "internal" partials #151
Make loader aware of "internal" partials #151
Conversation
As opposed to external partial which needs resolving, "internal" partial is defined in the same file (may be inline partial or failover content of unresolved partial block). If reference to it fails to resolve as external file, we need to check if the same file contains target partial
Thanks for the pull request! Do you think you can add some unit tests for this fix? |
I am actually not familiar with unit testing and testing in general. I read wiki on it a bit but still has no clue what to test and how... The only new "thing" is |
I will try it though |
Are my tests ok? |
Looks good! Thank you. I'll publish a new release in the next few days. |
@andreyvolokitin thank you for this PR! |
When partial is failing to be resolved there is an error thrown here, which interferes with the use of inline partials and failover content of partial blocks (#106, #135 ). Currently,
handlebars-loader
considers any partial names as external partials. But some partials with names not necessarily should be external (i.e. inline partials), or it may be acceptable to not have a resolved partial by this name if it is a partial block (which always has failover content).I used AST Visitor to save names of any partial blocks and
inline
decorators in the current template. In case of resolve error, I check if the name of a partial from failedrequest
is the one of those saved names and if that is the case I proceed withreturn partialCallback();
so that Handlebars can do all remaining work. In other case I pass error along as usual