Skip to content

Instantly share code, notes, and snippets.

@jtsagata
Forked from aurelian/controller.rb
Created February 3, 2011 22:56
Show Gist options
  • Save jtsagata/810400 to your computer and use it in GitHub Desktop.
Save jtsagata/810400 to your computer and use it in GitHub Desktop.
# ref: http://bit.ly/fN2ep8
# http://twitpic.com/3rr8dk
def sass_colors
engine= Sass::Engine.new(File.read("app/stylesheets/_colors.scss"), :syntax => :scss, :load_paths => ["app/stylesheets"])
environment= Sass::Environment.new
visitor = Sass::Tree::Visitors::Perform.new(environment)
engine.to_tree.children.each do | node |
next unless node.kind_of? Sass::Tree::VariableNode
visitor.send(:visit, node)
end
@sass_vars= environment.instance_variable_get("@vars").reject{|k| k == "important" }
end
%h2 SASS Colors
%table
%tr
%th Variable
%th Color
- @sass_vars.each do |var|
%tr
%td= "#{var[0]}: #{var[1]}"
%td{:style => "background-color:#{var[1]};width:80%;height:32px;"}  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment