grunt-contrib-htmlmin如何忽略模板标签 [英] grunt-contrib-htmlmin how to ignore template tags

查看:163
本文介绍了grunt-contrib-htmlmin如何忽略模板标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用grunt-contrib-htmlmin在backbone / underscorejs项目中缩小我的html,但是,当我在任何具有<%= myvar%>的underscorejs模板上运行grunt-contrib-htmlmin时,任务输出解析错误。有没有办法让grunt-contrib-htmlmin可以忽略<%=和%>里面的文本?

I'm using grunt-contrib-htmlmin to minify my html in a backbone/underscorejs project, however, when I run grunt-contrib-htmlmin on any underscorejs template that has <%= myvar %>, the task outputs a parse error. Is there a way grunt-contrib-htmlmin can ignore text inside <%= and %>?

推荐答案

问题,在 html-minifier (它被 grunt-contrib-htmlmin 使用)中引入了一项新功能, a href =https://github.com/kangax/html-minifier/compare/80fadd1b0bf8a3f4c9f13b940a855ec03a4337c3...d36a358d368747b9e86a6ee6ff37dbb55f2500e8 =nofollow> 忽略插值标记

Since you posted this issue, an new feature was introduced into html-minifier (which is used by grunt-contrib-htmlmin) to ignore the interpolation tags that were causing the problem.

例如,下面的html部分:

For instance, the following html partial:

<div>
    <span><%= variable %></span>
</div>

现在将缩小为:

Will now minify to:

<div><span><%= variable %></span></div>

在更改之前,会导致出错。

Before the changes, it would have resulted in an error.

您可以使用网站上的演示进行测试以进行测试。如果有效,您可以更新您的项目以使用新版本。

You can try this using the demo on the website to test it out. If that works, you can update your project to make use of the new version.

这篇关于grunt-contrib-htmlmin如何忽略模板标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆