I'm trying to build a large gallery with different sized tiles and was wondering how can I accomplish with a HAML each loop the following result?
.box.box-large
%img
.box.box-medium
%img
.box
%img
.box
%img
.box.box-large
%img
.box.box-double
%img
.box.box-full
%img
.box
%img
.box
%img
- n.times do
.box{class: decide_class}
%img
Here n is the integer number. N times the loop will be running. now in your Create a helper method named decide_class and return appropriate class for that loop
def decide_class
if (some condition to decide class)
'box-large' # return css class name as a string
else
'' # return empty string if you don't want to apply any class
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.