我目前有一个像这样的 html 模态块:
<div id="modal">
<div class="header_buttons"></div>
<p>
Are you sure you would like to perform <%= action_name %>
on <%= count %> objects?
</p>
<div class="footer_buttons">
<button>Do <%= action_name %></button>
</div>
</div>
我想通过解析这个内容_.template
$("#modal").html() //-> escapes `<%`
$("#modal").text() //-> doesn't escape, but doesn't include tags.
我的直接解决方案是针对每个元素而不是整个块,以便我可以使用text()
,但我很好奇这里是否有明显的解决方案?