Just ran across this trying to figure it out. Since it
sounds like
there's no solution, I brewed one up:
in lib/sass_ext.rb:
module Sass
module Constant
APP_CONFIG = YAML.load_file("#/config/
sass_constants.yml")[RAILS_ENV]
class << self
def get_constant(value, constants)
to_return = constants[value] || APP_CONFIG[value]
raise SyntaxError.new("Undefined constant:
"!#"")
unless to_return
to_return
end
end
end
end
in config/environment.rb:
require 'sass_ext'
in config/sass_constants.yml:
development:
host: "localhost:3000"
production:
host: "example.com"
test:
host: "localhost:3000"
in a .sass file:
:background-image = "url(http://" + !host +
"/images/foobar.png)"
I needed something like that so our CSS could be linked
remotely and
still work.
-Ian
On Jan 21, 7:41 am, Rue <thinla... gmail.com> wrote:
> It would be very useful to add application
configuration settings at
> sass=>css compile time. Otherwise you are forced to
replicate your
> global settings in your sass instead of simply:
>
> #thing
> width: APP_CONFIG['max_width']
>
> I agree that variables don't make a lot of sense
(variable css should
> be done inline) but setting certain values at
compile-time is very
> useful to the DRY app.
>
> anyone managed it yet?
>
> On Jan 18, 12:49 am, Nathan Weizenbaum <nex... gmail.com> wrote:
>
> > No. Sass isn't a view. In production mode, Sass
templates are compiled
> > once, independently of the request cycle, so it
doesn't make sense for
> > them to have access to Ruby variables.
>
> > jordanisip wrote:
> > > Hi All,
>
> > > Is there a way in SASS to do something like
this:
>
> > > !width = params[:width]
>
> > > OR
>
> > > #container
> > > :width = params[:width]
>
> > > Thanks in advance for the help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to haml googlegroups.com
To unsubscribe from this group, send email to
haml-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---
|