Module: FL::AssetHelper

Defined in:
app/helpers/fl/asset_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sass(hash, default = false) ⇒ Object

> Sass

> Takes HASH or YML and turns into SASS vars

> Used in config/initializers/sass.rb & assets/stylesheets/application.sass.erb



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/fl/asset_helper.rb', line 18

def self.sass hash, default=false
  vars = {}

  # Cycle through data
  # Recursion handled by "each_nested_pair"
  # Here you determine the best parts

  # Determine if hash is hash or path
  # If path change into hash by loading YML
  hash = YAML.load_file(hash) if hash.is_a?(String) || hash.is_a?(Pathname) # => Needs some sort of rescue

  # General
  # http://api.rubyonrails.org/classes/Hash.html#method-i-except
  hash.except("development", "production", "staging").each_nested_pair do |k,v|
    vars[k] = v if v
  end

  # Env
  if hash[Rails.env] # => Ensure that there is a key for the env
    hash[Rails.env].each_nested_pair do |k,v|
      vars[k] = v if v
    end
  end

  # Return
  vars.map{|k,v| "$#{k}: #{v} #{"!default" if default}"}.join("\n")
end

Instance Method Details

#sass(hash) ⇒ Object

> Sass



8
9
10
# File 'app/helpers/fl/asset_helper.rb', line 8

def sass hash
  self.sass hash
end