Skip to content

Instantly share code, notes, and snippets.

@lencioni
Created May 6, 2013 20:24
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 lencioni/5527890 to your computer and use it in GitHub Desktop.
Save lencioni/5527890 to your computer and use it in GitHub Desktop.
Example of evaluating values of sass variables
require 'sass'
class MyVisitor < Sass::Tree::Visitors::Base
def visit_variable(node)
@environment ||= Sass::Environment.new
@environment.set_local_var(node.name, node.expr)
puts node.expr.perform(@environment)
end
end
tree = Sass::Engine.for_file('test.scss', syntax: :scss).to_tree
MyVisitor.visit(tree) # Outputs "#eeeeee"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment