ruby - Creating scss variable in config.rb for scss files -


how define scss variable in config.rb scss file[ compass project ]

my use-case

in config.rb file like

a = true 

in style.scss use variable

@if == true{      background: #fff; }  @else {    background: #000; } 

one of solution http://worldhousefinder.com/?p=124141

but not worked me.

you can't/shouldn't this. precompile assets there no way of dynamically adapting changing variables. might work config.rb variable, bad pattern use , you'd have recompile assets every time change variable, defeats purpose of doing if else checks in sass.

a easier approach either add class .active .inactive on elements (body). or output inline css in head things custom colors etc depending on users signed in.

what trying do? sounds you'd check whether in production or development? in case like:

<body class='<%= "development" if rails.env == 'development' %>'> 

or even

<body <%= "style='background-color: red;'" if rails.env == 'development' %> 

you should never need use ruby in css , javascript, if find doing approaching in wrong way. @ least have found after many attempts nicely.

p.s. data-attributes effective way of passing variables, etc javascript


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -