Module: Rixius::Utils

Defined in:
lib/rixius/utils.rb

Instance Method Summary collapse

Instance Method Details

#css(*keys, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rixius/utils.rb', line 30

def css *keys, &block
  @css ||= []
  if block_given?
    @css.push capture_haml &block
  else 
    keys.each do |key|
      @css.push "<link rel=\"stylesheet\" href=\"/css/#{key}.css\">"
    end
  end
  nil
end

#css_dep(*keys, &block) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/rixius/utils.rb', line 41

def css_dep *keys, &block
  @css ||= []
  if block_given?
    @css = [ capture_haml(&block), *@css]
  end
  keys = keys.map {|key| "<link rel=\"stylesheet\" href=\"/css/#{key}.css\">" }
  @css = keys.push *@css
  nil
end

#css_render(*args, &block) ⇒ Object



50
51
52
53
54
# File 'lib/rixius/utils.rb', line 50

def css_render *args, &block
  @css ||= []
  css_dep *args, &block
  @css.join "\n"
end

#js(*keys, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/rixius/utils.rb', line 4

def js *keys, &block
  @js ||= []
  if block_given?
    @js.push capture_haml &block
  else 
    keys.each do |key|
      @js.push "<script src=\"/js/#{key}.js\"></script>"
    end
  end
  nil
end

#js_dep(*keys, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/rixius/utils.rb', line 15

def js_dep *keys, &block
  @js ||= []
  if block_given?
    @js = [ capture_haml(&block), *@js]
  end
  keys = keys.map {|key| "<script src=\"/js/#{key}.js\"></script>" }
  @js = keys.push *@js
  nil
end

#js_render(*args, &block) ⇒ Object



24
25
26
27
28
# File 'lib/rixius/utils.rb', line 24

def js_render *args, &block
  @js ||= []
  js_dep *args, &block
  @js.join "\n"
end