2017-05-12 30 views
0

使用Blaze,我如何写一个没有价值的属性?在一个属性中,只有一个字符串,没有=Blaze Templating - 属性没有价值

例如,我想在Blaze中添加一个YouTube嵌入,但我不知道如何添加allowfullscreen部分。来自html工具的blaze只是出错,并告诉我这在HTML5中是非法的,我不知道如何从文档中做到这一点。这里的HTML应该是什么样子:

<iframe width="560" height="315" 
    src="https://www.youtube.com/embed/T4r91mc8pbo" 
    frameborder="0" allowfullscreen> 
</iframe> 

我试图创建一个自定义元素像

allowfullscreen :: AttributeValue -> Attribute 
allowfullscreen = attribute "allowfullscreen" " allowfullscreen" 

,但它无论如何追加等号 - allowfullscreen"="和全屏是不允许的。

我使用了blaze-html 0.8.1.1和blaze-markup 0.7.0.3。

回答

1

布尔属性(HTML5 spec

如果该属性出现,其值必须是空字符串或者说是该属性的规范名称的ASCII不区分大小写匹配的值,没有前导或尾随白色空间。

实例

<label><input type=checkbox checked name=cheese disabled> Cheese</label> 
<label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label> 
<label><input type='checkbox' checked name=cheese disabled=""> Cheese</label> 

HTML4见。

这里有一个Github issue for blaze-html

所以allowfullscreen="allowfullscreen"应该工作。