-
Notifications
You must be signed in to change notification settings - Fork 9
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
retconAttr wrap script tags in an unexpected head tag #25
Comments
Hi @juban – that's odd, thanks for reporting. I'll take a look at it ASAP. Sidenote: If that's your actual template, you could use the native {% filter attr({ 'type': 'opt-in', 'data-type': 'application/javascript', 'data-name': 'google-analytics' }) %}
<!-- Google Tag Manager --><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-ZZZZZZ');</script>
<!-- End Google Tag Manager -->
{% endfilter %} |
Hi @mmikkel Thank you for your fast feedback. Indeed, the native attr filter is working fine in that use case. |
Hi @juban – I believe I might have a fix for this issue, if you'd be able to help me test it, that'd be great (the fix required a pretty fundamental change to how Retcon reads and writes HTML, so I won't push a release until I'm confident I didn't mess up something else). To install the fix, do
|
@mmikkel I'll try this ASAP and let you know. |
@mmikkel Looks pretty good to me. Did some tests on my projects and the bug is gone and I didn't notice any regression. I'm not using anything beside the |
@juban Thank you for the feedback. The fix basically changes all the filters (as it's changing how Retcon constructs the DOMDocument, and how it reads out the final HTML). If you have the time to test additional filters for regression errors or other weird behaviour, I'd appreciate it – but no worries if you don't :) |
Hi @mmikkel, I'll do my best ;) |
@juban Sure, if you find some time to do that it'd be much appreciated! |
Resolved in Retcon 2.2.0 |
Given the following twig template
the resulting generated code will be
instead of
Looks like the
getHtml
method is injecting thehead
tag when calling thesaveHTML
of the Mastermind HTML5 library (for some reason...).Changing the regex expression in
getHtml
method to strip the extra head tag seems to work, but could probably lead to some sides effects.The text was updated successfully, but these errors were encountered: