-
-
Save sskylar/7557528 to your computer and use it in GitHub Desktop.
{% capture html %} | |
<html> | |
... | |
</html> | |
{% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }} |
OMG! thank you so much for this! so simple, and so brilliant. used it to create javascript template files from liquid templates! 🔥
@sskylar Anyway this could work if you space your classes out like I do?
Source:
<header
class="
really-long-class-name
really-long-class-name--is-doing-stuff"
id="header">
...
</header>
Output:
<headerclass="really-long-class-namereally-long-class-name--is-doing-stuff"id="header">...</header>
+1
@mattmischuk that's the case right.
@agriboz whoa, a blast from the past. Now that prettier is a thing I don't really concern myself with these types of problems. Since 2015 there are many good html parsers and I wouldn’t recommend relying on liquid to do anything of the sort.
https://github.com/ikatyang/angular-html-parser/tree/master/packages/angular-html-parser
I say, move nonsense like this to a build step. Also, minifying HTML isn't really a big deal. I mean if you’re nutty about perf you’ll likely need to invest some time into learning how to minify HTML with a webpack, rollup, gulp task (or whatever Ruby alternative).
This should be a single filter called
minify
.