Closed rocc-o closed 1 year ago
@rocc-o I believe you'll want to pull out your srcdoc and store it in a variable, use double quotes (not single) for HTML attributes, and escape the resulting HTML (e.g., with a custom filter or a built-in one) before rendering it. For example, my eleventy-plugin-code-demo
plugin uses these lines of code to generate an iframe whose srcdoc
contains HTML:
I believe this is an issue with html-minifier
(specifically https://github.com/kangax/html-minifier/issues/762) and not Eleventy itself.
@AleksandrHovhannisyan What a very nice plugin! I'll definitely try it tomorrow. Thanks so much! @j-f1 I see. But never implemented since 2016!
@AleksandrHovhannisyan I'm installing your plugin but I get:
[11ty] Eleventy CLI Fatal Error: (more in DEBUG output)
[11ty] 1. Error in your Eleventy config file '.eleventy.js'. You may need to run `npm install`. (via EleventyConfigError)
[11ty] 2. Cannot find module 'lodash/escape'
So I tried npm i --save lodash.escape
and even npm install
but still the same error.
Node v16.13.0; NPM 8.1.0
@rocc-o Oh, that's strange! Let's move that particular discussion over to my repo: https://github.com/AleksandrHovhannisyan/eleventy-plugin-code-demo/issues/new?assignees=AleksandrHovhannisyan&labels=&template=bug_report.md&title=
Yes, thanks!
I'm minifying HTML output with Transform "html-minifier": "^4.0.0" plugin and "@11ty/eleventy": "^2.0.0"
Never had a problem. Now, when I'm trying to include an iframe with
srcdoc
attribute via components, like this:everything is minified but not what is inside the
srcdoc
attribute. I strongly suspect the single quotes which I am required to use inside thesrcdoc
attribute.Is there any way to fix this?