posthtml-extend
posthtml-extend copied to clipboard
Breaks with nested extends
container.html:
<div>
<block name="grid-children">
</block>
</div>
column.html:
<div>
<block name="col-children">
</block>
</div>
index.html: The following works fine as expected:
<extends src="./container.html">
<block name="grid-children"> -->
<div>this works</div>
</block>
</extends>
But the following breaks with Error: [posthtml-extend] Unexpected block "col-children":
<extends src="./container.html">
<block name="grid-children"> -->
<extends src="./column.html">
<block name="grid-children">
<div>this breaks</div>
</block>
</extends>
</block>
</extends>
@AdamDemirel Hi, sorry for the long answer. I was unable to reproduce your case https://github.com/posthtml-issues/posthtml-extend-issues-28. Could you make adjustments for reproduction?
@Scrum I've submitted a PR that duplicates the issue here: https://github.com/posthtml-issues/posthtml-extend-issues-28/pull/1
I've found that setting strict: false allows the build to succeed, so it looks like a bug in the type checking?
I've found that setting strict: false allows the build to succeed, so it looks like a bug in the type checking?
No, this is normal plugin behavior. He counts the block col-children undeclared for ./container.html and throws an exception
Whether the plugin should disallow undeclared block names.
By default, the plugin raises an exception if an undeclared block name is encountered. This can be useful for troubleshooting (i.e. detecting typos in block names), but there are cases where "forward declaring" a block name as an extension point for downstream templates is useful, so this restriction can be lifted by setting the strict option to a false value:
Oh interesting. I was bashing my head against a wall for several hours trying to figure out why it wasn't working. I think it'd be worth including examples of nested layouts and a warning about the strict checking.