6

Element needs a lot of class attributes but I don't want them to be chucked in one line, as the line length will be too long and it would require heavy side scrolling.

Preferably, I don't want to use the delimiter syntax [class= ""] as this syntax would be entirely inconsistent with the whole file.

I tried doing this way:

span.select2.select2-container.select2-container--default \
  .select2-container--below.select2-container--focus

But the \ and the remaining class attribute names just gets rendered as text.

Is there any possible way that I can chain class attributes in slim-lang a la ruby style, like this?

span.select2.select2-container.select2-container--default
    .additional-cssklass
    .whatever-class
jemonsanto
  • 513
  • 8
  • 19
  • 1
    You can find some useful syntax for slim [here](https://stackoverflow.com/questions/12851843/ruby-slim-how-do-you-define-an-elements-class-with-a-rails-helper-or-variable?answertab=active#tab-top). However, I think if you want to stick with current syntax then there is no way to do. – yeuem1vannam Dec 05 '17 at 06:59

1 Answers1

5

You need to use splat attribute that allows you to turn a hash into attribute/value pairs and then append a backslash to do multiline :

.first-class *{class: ["second-class", \
                       "third-class"]}
Snake
  • 1,157
  • 1
  • 10
  • 21