I am passing HTML as an attribute and would like to know if there is a function or a workaround to minify this inline HTML.
This is the link of how I’m passing the html to an iframe srcdoc: {{.Inner}} not working with iframe srcdoc? - #8 by DatsGabs
You could simply use hugo --minify
.
Not really, the whole app gets minified but not the attribute as it’s passed as a string
Have a look at the replaceRE
function to remove line breaks and spaces.
1 Like
Hugo does some minification of variables and “loops” if you use for instance property="{{ with $variable -}}{{- . -}}{{- end }}"
- this might help minify.
1 Like
bep
March 8, 2021, 1:12pm
6
I’m not sure how pretty it is, but:
{{ $html := "<h1>Hello</h1>" | resources.FromString "identifier.html" }}
{{ $minified := ($html | minify).Content
5 Likes
system
Closed
March 10, 2021, 1:12pm
7
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.