Can haml render <input type="text" required>
21,983
Solution 1
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
option is :html4
or :html5
, or as
<input required='required' type='text' />
if the format is :xhtml
.
If the value is false, it will be omitted altogether:
<input type='text' />
Solution 2
%input{type: "text", required: true}/
or
%input{:required => "", :type => "text"}/
Source: http://www.htmltohaml.com/
Solution 3
%input{:required => "", :type => "text"}/
Author by
Yujun Wu
Updated on July 12, 2022Comments
-
Yujun Wu almost 2 years
Haml can render
%input{:type=>"text"}
as
<input type="text">
Wonder what it should be in haml so it's rendered in html as
<input type="text" required>
Thanks