3

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%>&#58;&nbsp;</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]%>&#58;&nbsp;</span><span class="value"><%=props[0][1]%></span>
</p>
<p>
  <span class="prop"><%=props[1][0]%>&#58;&nbsp;</span><span class="value"><%=props[1][1]%></span>
</p>
<p>
  <span class="prop"><%=props[2][0]%>&#58;&nbsp;</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.

Dmitry Sadakov
  • 2,128
  • 3
  • 19
  • 34
Jas1234
  • 93
  • 9

1 Answers1

2

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.

Dmitry Sadakov
  • 2,128
  • 3
  • 19
  • 34