可以haml渲染<input type ="text"required>

Yuj*_* Wu 9 html5 haml ruby-on-rails

哈姆可以渲染

%input{:type=>"text"}
Run Code Online (Sandbox Code Playgroud)

<input type="text">
Run Code Online (Sandbox Code Playgroud)

想知道haml应该是什么,所以它在html中呈现为

<input type="text" required>
Run Code Online (Sandbox Code Playgroud)

谢谢

mat*_*att 13

如果属性值是布尔值,例如

%input{:type=>"text", :required => true}
Run Code Online (Sandbox Code Playgroud)

它将呈现为

<input required type='text'>
Run Code Online (Sandbox Code Playgroud)

如果format选项:html4:html5,或作为

<input required='required' type='text' />
Run Code Online (Sandbox Code Playgroud)

如果格式是:xhtml.

如果值为false,则将完全省略:

<input type='text' />
Run Code Online (Sandbox Code Playgroud)