Module: StylesheetsHelper

Defined in:
lib/css_dryer_2/stylesheets_helper.rb

Instance Method Summary collapse

Instance Method Details

#ie6(&block) ⇒ Object

<% ie6 do %>

css for ie6 here

<% end %>



8
9
10
# File 'lib/css_dryer_2/stylesheets_helper.rb', line 8

def ie6(&block)
  wrap '* html', &block
end

#ie7(&block) ⇒ Object

<% ie7 do %>

css for ie7 here

<% end %>



15
16
17
# File 'lib/css_dryer_2/stylesheets_helper.rb', line 15

def ie7(&block)
  wrap '* + html', &block
end

#include_file(filename) ⇒ Object

This actually ain’t cool. It simply allows to set variables in pure ruby code (no ERB for now). Ideally, we would want a method, that includes another erb-ed ncss files.



55
56
57
# File 'lib/css_dryer_2/stylesheets_helper.rb', line 55

def include_file(filename)
  eval File.read("#{RAILS_ROOT}/public/stylesheets/ncss/#{filename}")
end

#self_clear(*selectors) ⇒ Object

Self-clearing. For example:

<%= self_clear ‘div#foo’, ‘img.bar’, ‘p ul’ %>

You can pass a hash as the final argument with these options:

:clear => 'left' | 'right' | 'both' (default)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/css_dryer_2/stylesheets_helper.rb', line 25

def self_clear(*selectors)
  options = selectors.extract_options!
  clear = options[:clear] || 'both'

  selector_template = lambda { |proc| selectors.map{ |s| proc.call s }.join ', ' }

  p = lambda { |selector| "#{selector}:after" }
  q = lambda { |selector| "* html #{selector}" }
  r = lambda { |selector| "*:first-child+html #{selector}" }

  <<-END
  #{selector_template.call p} {
    content: ".";
    display: block;
    height: 0;
    clear: #{clear};
    visibility: hidden;
  }
  #{selector_template.call q} {
    height: 1%;
  }
  #{selector_template.call r} {
    min-height: 1px;
  }
  END
end