wondering if it is possible to use an array with Sass as I find my self repeating the following sort of thing:
.donkey
h2
background-color= !donkey
.giraffe
h2
background-color= !giraffe
.iguana
h2
background-color= !iguana
wondering if it is possible to use an array with Sass as I find my self repeating the following sort of thing:
.donkey
h2
background-color= !donkey
.giraffe
h2
background-color= !giraffe
.iguana
h2
background-color= !iguana
No, this isn t possible. The best way to do it is to define a mixin:
+animal-h2(!name, !color)
.#{name} h2
background-color= !color
Then you can have one line per style, rather than three:
+animal-h2("donkey", !donkey)
+animal-h2("giraffe", !giraffe)
+animal-h2("iguana", !iguana)
Absolutely.
$animals: "donkey", "giraffe", "iguana"
@foreach $animal in $animals
.#{$animal}
h2
background-color: !#{$animal}
nex3 s answer is correct. To get this working with SASS on Rails 3.1 I needed to have the following in a css.scss file:
$donkey: #CC4499;
@mixin animal-h2($name, $color) {
.#{$name} h2 {
background-color: $color;
}
}
@include animal-h2("donkey", $donkey);
@include animal-h2("horse", #000);
Which output:
.donkey h2 {
background-color: #CC4499;
}
.horse h2 {
background-color: black;
}
I m using rails.vim and I love how you can use ctrl-x ctrl-u in insert mode to autocomplete long method names like distance_of_time_in_words and accepts_nested_attributes_for. But for some reason it ...
I only want to output one anchor here. If the current_page is in the array I get two (.html and -nf.html). If it is not in the array I get as many anchors as there are items in the array. I am using ...
Is anyone using a HAML implementation for PHP like phpHaml or pHAML? Both projects have seen no activity for about 2 years, and both are < 1.0. Is it feasible/wise to use HAML for a large PHP ...
Is it possible to use Haml instead of a templating engine with the Catalyst web framework?
How do I reference a .sass file from a .haml file? I have the following haml expression that will reference a .css file: %link{ href => /stylesheets/layout.css?cache=1 , rel => stylesheet ...
I m a rails newbie, I ve been trying to figure out what is going on with the stylesheets_link_tag on heroku. If I use = stylesheet_link_tag "style", :cache => true heroku uses "all.css" and does ...
I have a config file full of this.... - if current_page.include? "test_string_one" - @total_index = 3 - @next_location = ../random_string/page0.html - @next_name = title 2 ...
There must be a better way of writing this- I m just not sure how (using staticmatic)- - if current_page.include? "0.html" - @current_index = 1 - if current_page.include? "1.html" - @...