html - HAML each loop add additional classes to nth elements -
i'm trying build big gallery different sized tiles , wondering how can accomplish haml each loop next 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 .box{class: decide_class} %img
here n integer number. n times loop running. in create helper method named decide_class , homecoming appropriate class loop
def decide_class if (some status decide class) 'box-large' # homecoming css class name string else '' # homecoming empty string if don't want apply class end end html loops for-loop haml each
No comments:
Post a Comment