...

/

Using Stimulus with Haml or Slim

Using Stimulus with Haml or Slim

Learn about Haml and Slim in this lesson.

We'll cover the following...

Since Stimulus depends so much on HTML attribute names, you might wonder how Stimulus works in HTML replacement tools like Haml and Slim.

Haml generally treats attribute lists as Ruby hashes, so you can do this:

%section.day-body{"data-controller": "day-toggle",
  "data-day-toggle-active": "false",
  "data-day-toggle-class-name": "is-hidden"}>

You need the quotation marks around the attribute names because Ruby symbol literals ...