How to set HTML5 attributes such as "required" using Slim template

I am creating a form using Slim template language and want to add the required attribute to my input.

 input#first_name(required name="first_name" type="text" pattern="^[AZ][az]+$") 

However, the HTML that is generated from this ends

  <input id="first_name" name="first_name" pattern="^[AZ][az]+$" required="" type="text" /> 

And this is not what I need.

I looked through the documents, but I see no way using Slim to add the standalone html5 attribute.

Similarly, adding the data-abide attribute to the form tag (as required by the Zurb Foundation environment) fails.

 form.custom(data-abide method="POST" action="/registration") 

leads to

 <form action="/registration" class="custom" data-abide="" method="POST"> 

What Zurb scripts are ignored.

What am I missing?

+10
html5 validation forms slim-lang required-field
source share
3 answers

In the * .html.slim file, do the following:

 input#first_name required="" name="first_name" type="text" pattern="^[AZ][az]+$" 

Note that the empty attribute syntax is:

 <input required> 

It is equivalent to:

 <input required=""> 
+4
source share

More readable would be:

 = f.input :email, required: true, autofocus: true 
+1
source share

Use this: -

= text_field_tag: user_name, "XYZ", read-only: true, required: true

0
source share

All Articles