Skip to content

Instantly share code, notes, and snippets.

@jonjaques
Forked from aurelian/controller.rb
Last active August 29, 2015 14:01
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 jonjaques/d8f18bbdc9f5a1872b4d to your computer and use it in GitHub Desktop.
Save jonjaques/d8f18bbdc9f5a1872b4d to your computer and use it in GitHub Desktop.
def sass_literals(file_path)
engine = Sass::Engine.for_file(file_path, {})
environment = Sass::Environment.new
keyvals = []
engine.to_tree.children.each do |node|
next unless node.kind_of? Sass::Tree::VariableNode
if node.expr.kind_of? Sass::Script::Tree::Literal
value = node.expr.perform(environment)
keyvals.push [node.name, value.to_s]
end
end
return keyvals
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment