-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Meta tag interpolation issue #2768
Comments
You're nesting the tags here, which isn't what you meant to do. Browsers often do odd thing when you nest tags that aren't meant to be nested. |
Other tags seem to handle this just fine i.e. the title. If you don't think its a bug I would still like you to solve the problem. For the record, given the following string |
By the way, it's not a one-off question. We are using react-helmet to manage our open graph tags. In our server side rendering we get the block of meta tags from react-helmet as strings and need to render this out in a template. |
Your code should be: html
head
!= metaTagTest
!= title
body This isn't a bug in pug, it is a quirk of how browsers handle nested tags they don't expect you to nest. If you look at the raw HTML output from pug (right click + view source), you will see pug works fine, but the browsers try to "fix" your markup, with varying results for different tags. |
aha! :-D I had no idea the syntax without a tag was valid! I assumed the tag name was required. Thank you very much for taking the time to point out this seemingly obvious solution. Definitely definitely not a bug in pug. Sorry for the misunderstanding. Cheers! |
While you're here, maybe you could add something to the docs to clarify this to other people? The docs are at https://github.com/pugjs/pug-en/tree/master/src if you would like to submit a pull request. From these docs, the https://pugjs.org website gets updated daily. |
I have found that meta tags don't interpolate the same way that title, div and other tags do. Leaving the
meta!= metaTagTest
line apparently is invalid syntax and will bring me to my error page. The title is totally fine though and the tag is replaced correctly. I expect both tags to behave the same way, but they do not.The text was updated successfully, but these errors were encountered: