Last active
August 29, 2015 14:07
-
-
Save rafapolo/817c28addb41f1859ca9 to your computer and use it in GitHub Desktop.
define número de elementos por colunas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# backend | |
def category_itens_per_col(total) | |
return case total | |
when 0..3 then 1 | |
when 4..6 then 2 | |
when 7..9 then 3 | |
else 4 | |
end | |
end | |
# frontend | |
- itens = category_itens_per_col(Category.count) | |
- Category.all.each_slice(itens) do |cs| | |
.col | |
- i = 0 | |
- cs.each do |c| | |
%p{style:'padding:10px'} | |
= set_spacing(i) | |
%a{href: url_to_category(c), class: 'category_item', img: c.image.url(:regular)}= c.name | |
- i+=1 | |
# css | |
.col | |
margin-left: 60px | |
display: inline-block | |
vertical-align: text-top |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set_spacing(3) => " "