使用EJS模板进行HTML验证;文本/模板”;元素

HTML validation with EJS templates as "text/template" elements

本文关键字:文本 模板 元素 验证 HTML EJS 使用      更新时间:2023-09-26

当使用像Backbone或Meteor这样的框架并从EJS模板在客户端构建视图时,对HTML验证的最新想法是什么?

问题似乎是name不是<script>标签的官方属性。

我的代码看起来像:

<div id="templates">
<script name="template_name" type="text/template">
  <p class="summary">
    <img src="<%= this.model.image() %>"/>
    <br/>
    <%= this.model.summary() %>
  </p>
  <div>
    <%= this.model.content() %>
  </div>
</script>
<!-- etc... -->
</div>

验证错误为

Attribute name not allowed on element script at this point.
<script name='hover_grid' type='text/template'>
Attributes for element script:
Global attributes
src
async
defer
type
charset

我是在等待这种方法得到支持和辩护,还是有办法使这种标记有效?

我认为name实际上是id

<script id="template_name" type="text/template">