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
  • Select an option

  • Save jonjaques/d8f18bbdc9f5a1872b4d to your computer and use it in GitHub Desktop.

Select an option

Save jonjaques/d8f18bbdc9f5a1872b4d to your computer and use it in GitHub Desktop.

Revisions

  1. jonjaques revised this gist May 29, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    def sass_literals(file)
    def sass_literals(file_path)
    engine = Sass::Engine.for_file(file_path, {})
    environment = Sass::Environment.new

  2. jonjaques revised this gist May 29, 2014. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,16 @@
    def sass_literals(file)
    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
    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
  3. jonjaques revised this gist May 29, 2014. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,16 @@
    def sass_literals(file)
    engine = Sass::Engine.for_file(file_path, {})
    environment = Sass::Environment.new
    environment = Sass::Environment.new

    keyvals = []
    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
    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

    return keyvals
    end

    return keyvals
    end
  4. jonjaques revised this gist May 29, 2014. 2 changed files with 15 additions and 23 deletions.
    27 changes: 15 additions & 12 deletions controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,16 @@

    # 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
    engine.to_tree.children.each do | node |
    next unless node.kind_of? Sass::Tree::VariableNode
    node.perform environment
    end
    def sass_literals(file)
    engine = Sass::Engine.for_file(file_path, {})
    environment = Sass::Environment.new

    @sass_vars= environment.instance_variable_get("@vars").reject{|k| k == "important" }
    end
    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
    11 changes: 0 additions & 11 deletions sass_colors.html.haml
    Original file line number Diff line number Diff line change
    @@ -1,11 +0,0 @@
    %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;"}  
  5. @aurelian aurelian revised this gist Jan 20, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@

    # 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
  6. @aurelian aurelian revised this gist Jan 20, 2011. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions sass_colors.html.haml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    %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;"}  
  7. @aurelian aurelian renamed this gist Jan 20, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. @aurelian aurelian created this gist Jan 20, 2011.
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    def sass_colors
    engine= Sass::Engine.new(File.read("app/stylesheets/_colors.scss"), :syntax => :scss, :load_paths => ["app/stylesheets"])
    environment= Sass::Environment.new
    engine.to_tree.children.each do | node |
    next unless node.kind_of? Sass::Tree::VariableNode
    node.perform environment
    end

    @sass_vars= environment.instance_variable_get("@vars").reject{|k| k == "important" }
    end