Skip to content

Instantly share code, notes, and snippets.

@rkh
Created June 7, 2010 16:20
Show Gist options
  • Save rkh/428874 to your computer and use it in GitHub Desktop.
Save rkh/428874 to your computer and use it in GitHub Desktop.
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
#header
background: url_for('background_image')
@jalcine
Copy link

jalcine commented Jul 5, 2012

How do I integrate this with Rails? Like where would I add it?

@rkh
Copy link
Author

rkh commented Jul 5, 2012

I'd add it somewhere in lib and load it in an initializer, for example.

@rkh
Copy link
Author

rkh commented Jul 5, 2012

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