Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a multi-line class attribute with slim-rails?

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
like image 937
jemonsanto Avatar asked Dec 05 '17 05:12

jemonsanto


1 Answers

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"]}
like image 87
Snake Avatar answered Sep 18 '22 02:09

Snake