Hello there. I had used lodash template tags for my widget. It worked well until I updated Hugo from 0.18.1 to 0.19.
% hugo version
Hugo Static Site Generator v0.19 darwin/amd64 BuildDate: 2017-02-27T19:21:29+09:00
In 0.19, some tags are escaped after the build. The template with the problem is below:
<script type="text/template" id="js-qiita-posts-tmpl">
<% list.forEach(function (item) { %>
<li class="qiita-tl__item">
<a class="qiita-tl__link" href="<%= item.url %>" target="_blank">
<span class="qiita-tl__stock" target="_blank">
<%= item.stock_count %> <span class="qiita-tl__stock-unit">STOCKS</span>
</span>
<h3 class="qiita-tl__title"><%= item.title %></h3>
<p class="qiita-tl__tags">
<% item.tags.forEach(function (tag) { %>
<span class="qiita-tl__tag"><%= tag.name %></span>
<% }); %>
</p>
</a>
</li>
<% }); %>
</script>
The output from 0.19 is this:
<script type="text/template" id="js-qiita-posts-tmpl">
<% list.forEach(function (item) { %>
<li class="qiita-tl__item">
<a class="qiita-tl__link" href="<%= item.url %>" target="_blank">
<span class="qiita-tl__stock" target="_blank">
<%= item.stock_count %> <span class="qiita-tl__stock-unit">STOCKS</span>
</span>
<h3 class="qiita-tl__title"><%= item.title %></h3>
<p class="qiita-tl__tags">
<% item.tags.forEach(function (tag) { %>
<span class="qiita-tl__tag"><%= tag.name %></span>
<% }); %>
</p>
</a>
</li>
<% }); %>
</script>
The lodash tags outside double quotes are escaped unexpectedly. I also tried these functions but the result isn’t desirable.
template:
{{ printf "<%= contribution %>" }}
{{ htmlUnescape "<%= contribution %>" }}
{{ htmlUnescape "<%= contribution %>" }}
output:
<%!=(MISSING) contribution %!>(MISSING)
<%= contribution %>
<%= contribution %>
Currently, I haven’t tried 0.20, because it hasn’t appeared to Homebrew, yet.
My questions :
- Is it a bug? or new expected behavior from 0.19?
- Are there any solutions to keep lodash tags unescaped?