Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 333
Yujun Wu Avatar asked Mar 29 '13 17:03

Yujun Wu


3 Answers

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' />
like image 190
matt Avatar answered Sep 29 '22 10:09

matt


%input{type: "text", required: true}/

or

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

Source: http://www.htmltohaml.com/

like image 40
Luís Ramalho Avatar answered Sep 29 '22 09:09

Luís Ramalho


%input{:required => "", :type => "text"}/
like image 26
Ganesh Kunwar Avatar answered Sep 29 '22 09:09

Ganesh Kunwar