Question

I'm really new to HTML and I want to achieve the following thing:

<div class="column_1"></div>
<div class="column_2"></div>
<div class="column_3"></div>
<div class="column_4"></div>

I tried this one

  - (1..4).each do |i|
    .column #{i}

This generates the columns but the increment is in the content from the div and not part of the class name.

Hope someone can help me to show me the correct way ;)

Was it helpful?

Solution

You can’t use the CSS style syntax (. and #) to generate dynamic attributes like that, you need to do it like this:

- (1..4).each do |i|
  %div{:class => "column_#{i}"}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top