For some reason sass isn't running my custom function. The environment variable is defined and working as I have other ruby code that uses it within the app. I just can't figure out why SASS isn't running the function. I appreciate your help.
I have a custom sass method located in the application.rb file:
module Sass::Script::Functions
def get_env
Sass::Script::String.new(ENV['THE_ENV'])
end
declare :get_env, args: []
end
THE_ENV
environment variable is defined in the application.yml file.
In my application.sass file I have the following, It's always setting #d71f2b:
$primary_color: #d71f2b
@if get_env() == "xyz"
$primary_color: #39A163
@else
$primary_color: #d71f2b
Gemfile.lock contains:
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
I figured it out. My application.yml file shows
THE_ENV: xyz
. The sass ruby code is looking for"xyz"
including the quotes. I removed the quotes from the sass ruby if/else statement and it worked. So it looks like: