Module: Helpers

Defined in:
lib/vitae/server/helpers.rb

Instance Method Summary collapse

Instance Method Details

#content_tag(*args, &block) ⇒ Object



18
19
20
21
# File 'lib/vitae/server/helpers.rb', line 18

def (*args, &block)
  args.last[:double_tag] = true if args.last.is_a?(Hash)
  tag(*args, &block)
end

#current_themeObject



2
3
4
# File 'lib/vitae/server/helpers.rb', line 2

def current_theme
  @cv && @cv.theme || "default"
end

#include_theme_assetsObject



6
7
8
9
10
# File 'lib/vitae/server/helpers.rb', line 6

def include_theme_assets
  html = (:script, nil, :type => "text/javascript", :src => "/#{current_theme}/application.js")
  html << "\n"+tag(:link, nil, :type => "text/css", :media => "screen", :rel => "stylesheet", :href => "/#{current_theme}/application.css")
  html
end


12
13
14
15
16
# File 'lib/vitae/server/helpers.rb', line 12

def link_to(text, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  link = args.first || text.split(/\s+/).join('_').downcase
   :a, text, options.merge({:href => link})
end

#tag(*args, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vitae/server/helpers.rb', line 23

def tag(*args, &block)
  name = args.first
  
  options = args.last.is_a?(Hash) ? args.pop : {}
  double_tag = options.delete(:double_tag)
  
  attrs = if options.size>0
    " "+options.map { |k,v| "#{k}='#{v}'" }.join(" ")
  else
    ""
  end
  tag_html = block_given? ? capture_html(&block) : args[1]
  
  "<#{name}#{attrs}"+(tag_html||double_tag ? ">#{tag_html}</#{name}>" : "/>")
end