attributes - Jade : element attributes without value

标签 attributes pug

我是使用 Jade 的新手——到目前为止它很棒。

但是我需要发生的一件事是具有“itemscope”属性的元素:

<header itemscope itemtype="http://schema.org/WPHeader">

我的 Jade 符是:
header(itemscope, itemtype='http://schema.org/WPHeader')

但结果是:
<header itemscope="itemscope" itemtype="http://schema.org/WPHeader">

我怎样才能确保得到正确的结果 -- itemscope而不是 itemscope="itemscope" ?

最佳答案

我刚刚在 Express.js/Jade 项目中尝试过,得到的结果是:

<header itemscope itemtype="http://schema.org/WPHeader"></header>

我也在 bash 中尝试过,然后得到和你一样的结果。

我会采用以下建议或在 Github 上创建问题。

itemscope="itemscope" will work just as well as just itemscope. It looks like that's the default behavior of Jade. I'd just go with it.

关于attributes - Jade : element attributes without value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11020142/

相关文章:

php - Laravel 获取模型属性 : difference between two methods

javascript - jQuery 将属性集作为字符串插入到标签中

node.js - 创建一个包含用户信息的jade默认布局

javascript - 谷歌地图需要很长时间才能加载

javascript - Node.js,哈巴狗。如何设置另一个 pug 文件的链接

c# - 我如何使用反射找到数据注释属性及其参数

c# - 为什么 C# 编译器生成错误,即使使用属性 "SpecialName"

c# - 以编程方式向方法或参数添加属性

javascript - node.js+express+jade : style. css 内部服务器错误 500

html - Jade 渲染后如何在两个 <div> 之间添加一个空格字符?