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 ;)

有帮助吗?

解决方案

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}"}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top