posthtml-parser icon indicating copy to clipboard operation
posthtml-parser copied to clipboard

Block in title results in unexpected block

Open MattIPv4 opened this issue 5 years ago • 4 comments
trafficstars

With [email protected] & [email protected], the following works just fine:

<html>
    <head>
        <title><block name="title"></block> — Github</title>
    </head>

    <body>
        <div class="content">
           <block name="content"></block>
        </div>
    </body>
</html>
<extends src="base.html">
    <block name="title">How to use posthtml-extend</block>
    <block name="content">Read the documentation</block>
</extends>

With [email protected] & posthtml-extend@0.5.1, it errors:

[posthtml-extend] Unexpected block "title"
    at getError (node_modules/posthtml-extend/lib/extend.js:228:12)
    at mergeExtendsAndLayout (node_modules/posthtml-extend/lib/extend.js:156:23)
    at node_modules/posthtml-extend/lib/extend.js:91:31
    at node_modules/posthtml/lib/api.js:91:45
    at traverse (node_modules/posthtml/lib/api.js:105:26)
    at Array.match (node_modules/posthtml/lib/api.js:90:7)
    at handleExtendsNodes (node_modules/posthtml-extend/lib/extend.js:81:16)
    at node_modules/posthtml-extend/lib/extend.js:45:16
    at node_modules/parcel-bundler/node_modules/posthtml/lib/index.js:188:14
    at tryCatch (node_modules/parcel-bundler/node_modules/posthtml/lib/index.js:271:12)

MattIPv4 avatar Nov 12 '20 11:11 MattIPv4

@MattIPv4 Hi, thanks for contacting us. The reason lies in the parsing that we recently updated.

Now we are solving this problem, I can offer as an alternative to use such a block

base.html

<head>
  <block name="title"><title> — Github</title></block>
</head>

index.html

<block name="title"><title>How to use posthtml-extend</title></block>

Scrum avatar Nov 13 '20 10:11 Scrum

Changing how we generate the base template would be a pretty major breaking change across a load of our projects -- if this dependency bump has caused a breaking change for the library, that should really be a major version release, not a patch (which it was)?

MattIPv4 avatar Nov 13 '20 11:11 MattIPv4

Changing how we generate the base template would be a pretty major breaking change across a load of our projects -- if this dependency bump has caused a breaking change for the library, that should really be a major version release, not a patch (which it was)?

Yes, you are definitely right. I will try to settle this moment

Scrum avatar Nov 13 '20 12:11 Scrum

@MattIPv4 @cossssmin This is a temporary solution for the transition to a new version of posthtml, it must be included in your project at the very beginning of the plugins

Scrum avatar Nov 26 '20 15:11 Scrum