我想缩小我的 .html 文件。我试着用 grunt-contrib-htmlmin 缩小, grunt-processhtml .他们实际上无法缩小。然后我意识到我所有的 html 元素都包含在 jQuery.tmpl 中.这些缩小工具似乎不涉及脚本标签。所以我有一堆模板如下所示:
<script id='wrapper' type='text/x-jquery-tmpl'>
<div class='person-wrapper'>
{{html $item.html()}}
</div>
<!-- many html tags -->
</script>
我的问题是如何缩小 (jQuery.tmpl) 模板?我正在使用 Gruntjs 来缩小 .css、.js 文件。但任何工具或插件都值得赞赏。
最佳答案
尝试查看 htmlcompressor .根据他们的文档,它应该压缩模板标签内的代码:
Any content within
<pre>
,<textarea>
,<script>
and<style>
tags will be preserved and remain untouched (with the exception of<script type="text/x-jquery-tmpl">
tags which are compressed as HTML).
它是 Java 库,但它也有 grunt plugin .
希望对您有所帮助。
关于javascript - 缩小 jQuery tmpl html 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21462615/