Read more

Haml: Prefixing a group of attributes

Henning Koch
July 14, 2018Software engineer at makandra GmbH

Haml lets you prefix a group of attributes by wrapping them in a hash. This is only possible with the {} attribute syntax, not with the () attribute syntax.

Example: HTML5 data attributes

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

HTML5 allows you to use arbitrary attributes like data-method and data-confirm. You can prefix a group of data- attributes like this:

%a{href: '/path', data: { method: 'delete', confirm: 'Really delete?' }} Label

This compiles to:

<a data-confirm='Really delete?' data-method='delete' href='/path'>Label</a>

Example: Unpoly attributes

You might also want to use this to define multiple Unpoly Show archive.org snapshot attributes, which are all prefixed by up-:

%a{href: '/path', up: { target: '.element', transition: 'zoom-in' }} Label

This compiles to:

<a href='/path' up-target='.element' up-transition='zoom-in'>Label</a>
Posted by Henning Koch to makandra dev (2018-07-14 07:32)