문제

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