Html 可以 Haml 渲染 <input type="text" required>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15708532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can haml render <input type="text" required>
提问by Yujun Wu
Haml can render
Haml 可以渲染
%input{:type=>"text"}
as
作为
<input type="text">
Wonder what it should be in haml so it's rendered in html as
想知道它应该在 haml 中是什么,所以它在 html 中呈现为
<input type="text" required>
Thanks
谢谢
回答by matt
If the value of an attribute is a boolean, e.g.
%input{:type=>"text", :required => true}
it will be rendered as either
它将被呈现为
<input required type='text'>
if the format
optionis :html4
or :html5
, or as
如果format
选项是:html4
或:html5
,或作为
<input required='required' type='text' />
if the format is :xhtml
.
如果格式是:xhtml
.
If the value is false, it will be omitted altogether:
如果值为 false,则将完全省略:
<input type='text' />
回答by Luís Ramalho
%input{type: "text", required: true}/
%input{type: "text", required: true}/
or
或者
%input{:required => "", :type => "text"}/
%input{:required => "", :type => "text"}/
Source: http://www.htmltohaml.com/
回答by Ganesh Kunwar
%input{:required => "", :type => "text"}/