Theres a way to loop on slim a html element?

I'd like to loop this on slim:

.row.vh14.sand_bg.relative
  .col-lg-6.col-lg-offset-3.fill_top_60px
    .trabajo.col-lg-4.test_img.vh5
    .trabajo.col-lg-4.test_img.vh5
    .trabajo.col-lg-4.test_img.vh5
    .trabajo.col-lg-4.test_img.vh5
    .trabajo.col-lg-4.test_img.vh5
    .trabajo.col-lg-4.test_img.vh5

but no one by one, something like less loops o similar way,just define the number of iteration neededa and voila.

something:

element x (5) = element element element element element

Upvotes: 0

Views: 715

Answers (2)

rohin-arka
rohin-arka

Reputation: 799

Using for loop you can do it as below example.

.row.vh14.sand_bg.relative
  .col-lg-6.col-lg-offset-3.fill_top_60px
   - for item in (1..6) # you can define your range how many times you want to loop 
    .trabajo.col-lg-4.test_img.vh5

UPDATED

I think slim indentation is causing problem..

 .row.vh14.sand_bg.relative
   .col-lg-6.col-lg-offset-3.fill_top_60px
     - for item in (1..6) # you can define your range how many times you want to loop 
        .trabajo.col-lg-4.test_img.vh5

Upvotes: 0

Ursus
Ursus

Reputation: 30071

Have you tried something like

- 5.times do
   .trabajo.col-lg-4.test_img.vh5

?

Upvotes: 1

Related Questions