Skip to content
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

Block in title results in unexpected block #53

Open
MattIPv4 opened this issue Nov 12, 2020 · 4 comments
Open

Block in title results in unexpected block #53

MattIPv4 opened this issue Nov 12, 2020 · 4 comments

Comments

@MattIPv4
Copy link

With posthtml@0.13.4 & posthtml-extend@0.5.0, 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 posthtml@0.13.4 & 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 MattIPv4 changed the title Block in title appears to fail Block in title results in unexpected block Nov 12, 2020
@Scrum
Copy link
Member

Scrum commented Nov 13, 2020

@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>

@MattIPv4
Copy link
Author

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)?

@Scrum
Copy link
Member

Scrum commented Nov 13, 2020

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 added a commit that referenced this issue Nov 13, 2020
fix: downgrade htmlpareser2 to 3* version, issue #53
@Scrum
Copy link
Member

Scrum commented Nov 26, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants