Skip to content

Instantly share code, notes, and snippets.

@ahoward
Last active December 16, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahoward/7c4c282efc4c493ca8caab6ee4e482d3 to your computer and use it in GitHub Desktop.
Save ahoward/7c4c282efc4c493ca8caab6ee4e482d3 to your computer and use it in GitHub Desktop.
using sass expressions and all your rails' sass helpers in erb / eruby
module ApplicationHelper
# <%= sass_eval 'opacify($red, 0.6)' %>
def sass_eval(expr)
css = ::Sass.compile("#value { value: #{ expr }; }") # ".value {\n value: $sass_processed_arg; }\n"
css.split('value:', 2).last.split(';', 2).first.strip
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment