-
Notifications
You must be signed in to change notification settings - Fork 16
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
Partial with {{> @partial-block }}
should not be rendered when processed as stand-alone templates
#3
Comments
Thanks for the report, @teehemkay! |
{{> @partial-block }}
should not be rendered when as stand-alone templates{{> @partial-block }}
should not be rendered when processed as stand-alone templates
What I think is happening is that Handlebars is being fed a template A that includes a In such a context Handlebars runtime seems to interpret the In "normal" Handlebars use case such a situation would typically be an error since template A doesn't make much sense as a "stand-alone" template. But PL, tries to render every template. And there in lies the problem. So my current understanding is that Also I've looked at the code of the hbs engine and it seems to be doing the right thing by not recognizing @partial-block as the name of a partial.
|
@geoffp On Gitter, @bmuenzenmeyer was kind enough to provide some pointers to the main modules involved in how the engines are hooked up to the core PL. This has enabled me to modify the hbs engine as follows to correct this issue in basically 3 steps: First add a findAtPartialBlockRE: /{{#?>\s*@partial-block\s*}}/g` Second add an function(partialString) {
var partial = partialString.replace(this.findAtPartialBlockRE, '{{> @partial-block }}')
return partial;
} And third add the following line to in pattern.extendedTemplate = this.escapeAtPartialBlock(pattern.extendedTemplate); This solved the issue for me. @geoffp Please let me know if you want me to create a pull request |
@teehemkay excellent work. I would love a pull request, with three requests:
I'll be out of town for a week, so no rush. |
Also, I think this is my old, personal repo for patternengine-node-handlebars -- I think we should be doing this at https://github.com/pattern-lab/patternengine-node-handlebars instead. Just noticed that! |
@geoffp Cool. I'll create the PRs later this week. |
@geoffp re: point 2. above: it doesn't work to call The escaping must only occur when a partial with a |
@teehemkay -- good find. Thanks for trying it. I'll check out the PR. |
Let me know if / when pattern-lab/patternlab-node#548 can be merged. Sounds like this is still baking? |
@geoffp my PR @ pattern-lab/patternlab-node#548 contains tests for this PR. One of them will keep failing as long as this PR as not been accepted... |
Cool. I'll review and hopefully merge ASAP. |
I am using Pattern Lab Node edition-node-gulp@1.3.2 with patternengine-node-handlebars@1.0.0
Expected Behavior
Let's suppose we have the following two templates:
Template
foo.hbs
:Template
bar.hbs
:I would expect this to render as:
Actual Behavior
Instead I get the following error message:
Steps to Reproduce
The text was updated successfully, but these errors were encountered: