I m laying out a form using the Slim template language and want to add the required
attribute to my input.
input#first_name(required name="first_name" type="text" pattern="^[A-Z][a-z]+$")
However the HTML that is generated from this ends up being
<input id="first_name" name="first_name" pattern="^[A-Z][a-z]+$" required="" type="text" />
And that's not what I need.
I've gone through the docs but can't see any way with Slim to add a standalone html5 attribute.
Likewise adding the data-abide
attribute to the form
tag (as required by the Zurb Foundation framework) fails.
form.custom(data-abide method="POST" action="/registration")
leads to
<form action="/registration" class="custom" data-abide="" method="POST">
Which the Zurb scripts ignore.
What am I missing?
Slim is a template language whose goal is to reduce the view syntax to the essential parts without becoming cryptic. It started as an exercise to see how much could be removed from a standard html template (<, >, closing tags, etc...).
What's Slim? Slim is a page-templating language that minimizes markup and syntax. It removes most of the extra "programming-like" symbols from HTML so that your code looks cleaner. Slim also adds if-else statements, loops, includes, and more.
In your *.html.slim file do:
input#first_name required="" name="first_name" type="text" pattern="^[A-Z][a-z]+$"
Note that empty attribute syntax:
<input required>
Is equivalent to:
<input required="">
More readable would be:
= f.input :email, required: true, autofocus: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With