Created
June 7, 2010 16:20
-
-
Save rkh/428874 to your computer and use it in GitHub Desktop.
This file contains 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
module VarAccessor | |
Sass::Script::Functions.send :include, self | |
def self.variables | |
@variables ||= {} | |
end | |
def self.set(values = {}) | |
variables.merge! values | |
end | |
def variable(value) | |
VarAccessor.variables[:"#{value}"] | |
end | |
def url_for(value) | |
"url(#{variable(value)})" | |
end | |
end | |
VarAccessor.set :background_image => @company.settings.banner.url |
This file contains 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
#header | |
background: url_for('background_image') |
Also, I am not sure this still works with the latest Sass, but it might.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd add it somewhere in lib and load it in an initializer, for example.