Method: Slideshow::BackgroundHelper#color

Defined in:
lib/slideshow/helpers/background_helper.rb

#color(*args) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/slideshow/helpers/background_helper.rb', line 117

def color( *args  )
  
 # make everyting optional; use it like: 
 #   color( code, opts={} )
  
  # check for optional hash for options
  opts = args.last.kind_of?(Hash) ? args.pop : {}

  # check for optional style rule code
  code = args.last.kind_of?(String) ? args.pop : '' 
    
  clazz = opts[:class] || ( 's9'+code.strip.gsub( /[(), ]/, '_' ).gsub( /_{2,}/, '_').gsub( /[^-\w]/, '' ) )
  
  # 1) add color rule to css 
  # e.g. .simple { color: #fff; }
  
  unless code.empty?
    puts "  Adding CSS for color style rule..."  
    content_for( :css, "      .\#{clazz} { color: \#{code}; }\n    EOS\n  end\n  \n  # 2) add processing instruction to get style class added to slide \n\n  puts \"  Adding HTML PI for color style class '\#{clazz}'...\"    \n  \"<!-- _S9STYLE_ \#{clazz} -->\\n\"\nend\n" )