Skip to content

Content gets not rendered #86

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

Closed
may17 opened this issue Apr 29, 2022 · 14 comments
Closed

Content gets not rendered #86

may17 opened this issue Apr 29, 2022 · 14 comments

Comments

@may17
Copy link

may17 commented Apr 29, 2022

Hi seems like that the content gets not rendered correctly? Maybe i did something wrong?

This is my module

<a href="{{ url }}" class="mt-3 text-sm text-indigo-500">
  <content></content>
</a>

I use my module like this:

<module href="/doclink.html" locals='{"url": "https://tooanywebpage.org/"}'>Foobar</module>

The rendered result will be

<a href="https://tooanywebpage.org/" class="mt-3 text-sm text-indigo-500">
  <content></content>
</a>
@gavmck
Copy link

gavmck commented May 3, 2022

Same issue here, looks like the matcher returns { tag: 'content', attrs: {} }, which fails, but { tag: 'content' } seems to work. Spent a couple of hours digging, but not sure where the exact failure point is.

@cossssmin
Copy link
Member

Hmm I think the recently-released posthtml-match-helper (1.0.2) might be what's causing it. Just tested with 1.0.1 and it all works as expected.

@phloe can you please check and let us know, I can also confirm I'm getting <content></content> output as-is with the latest posthtml-match-helper that posthtml-modules depends on.

@cossssmin
Copy link
Member

So this is where we try to replace the <content> tag with what you pass into the module:

const content = tree.match(match('content'), () => {

Given that this code above it works to match the tag:

tree.match(match(`${options.tag}[${options.attribute}]`), node => {

... I wonder if that missing attribute is what's causing it.

@cossssmin
Copy link
Member

Created #87 to get started with fixing this, though I'm not really sure how to go about it 🤔

I've updated the dependencies just in case, so we're working with current versions and are not running into any old bugs that may have been fixed. @Scrum if you could also have a look, please.

@gavmck
Copy link

gavmck commented May 3, 2022

Locally, I've installed posthtml-matcher-helper@1.0.1 to bypass the issue whilst you're looking at it.

@cossssmin
Copy link
Member

Yeah, that works as a workaround 👍

We'll need to get this fixed though as it's currently breaking for everyone and they might have no clue where it's coming from since there are no errors or anything...

@phloe
Copy link

phloe commented May 3, 2022

The error is in posthtml-match-helper? Yikes.

The 1.0.2 bump was only supposed to have added TypeScript types...

@cossssmin
Copy link
Member

Yeah, can't understand what's causing it but 1.0.1 does work fine 🤔

@phloe
Copy link

phloe commented May 3, 2022

I hope it's fixed now with posthtml-match-helper@1.0.3

New bug was attrs was always added to the match object:

match('content') // -> { tag: 'content', attrs: {} }

used to be

match('content') // -> { tag: 'content' }

failing to match tags with no attributes - but matching if they had any.

Also - empty attributes never worked (not a new bug - but fixed in 1.0.3):

match('content[]')

@cossssmin
Copy link
Member

Thanks Rasmus, appreciate the fast response! Bumped it in #87 and tests are passing again 👍

Would you maybe consider adding some tests to posthtml-match-helper so we minimize the risk of such issues? 🙏

@phloe
Copy link

phloe commented May 3, 2022

YES! 😅

@cossssmin
Copy link
Member

@may17 and @gavmck can you please confirm that 1.0.3 now works for you as well? Thanks!

@gavmck
Copy link

gavmck commented May 3, 2022

@cossssmin Works for me on 1.0.3 ✅

@may17
Copy link
Author

may17 commented May 6, 2022

Sorry for the delayed response. Works as expected now! Thx a lot.

@may17 may17 closed this as completed May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants