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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:00:19  来源:igfitidea点击:

Can haml render <input type="text" required>

ruby-on-railshtmlhaml

提问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 formatoptionis :html4or :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/

来源:http: //www.htmltohaml.com/

回答by Ganesh Kunwar

%input{:required => "", :type => "text"}/

回答by bonyiii

%input(type="text" required=true)

html style attributes

html样式属性