My html file looks like
<% for (var i = 0, l = props.length; i < l; ++i) {
var _name = props[i][0];
var _value = props[i][1]; %>
<p>
<span class="prop"><%=_name%>: </span><span class="value"><%=_value%></span>
</p>
<% } %>
I get a html parse error in the for loop.
Warning: Command failed: /Users/xx/xx/xxxxx/node_modules/html-minifier/dist/htmlminifier.js throw 'Parse Error: ' + html; ^ Parse Error:
I don't know what the even means. I checked at the props array it is giving me the correct data.
props = [["a","b"],["c","d"],["e","f"]]
The html does give correct values when i print them out static.
<p>
<span class="prop"><%=props[0][0]%>: </span><span class="value"><%=props[0][1]%></span>
</p>
<p>
<span class="prop"><%=props[1][0]%>: </span><span class="value"><%=props[1][1]%></span>
</p>
<p>
<span class="prop"><%=props[2][0]%>: </span><span class="value"><%=props[2][1]%></span>
</p>
This gives me the required result.
But i want to know how to fix the parse error in the for loop.
It seems you are using a html-minifier on a non-plain html files, with special server tags such as <% and <%=_value%>. You should use the minification process on only resulting html files from the server, not on templates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With