Module: Helpers

Included in:
Vitae::Nodes::Node
Defined in:
lib/vitae/server/helpers.rb

Instance Method Summary collapse

Instance Method Details

#content_tag(*args, &block) ⇒ Object



20
21
22
23
# File 'lib/vitae/server/helpers.rb', line 20

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_cssObject



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

def include_theme_css
  tag(:link, nil, :type => "text/css", :media => "screen", :rel => "stylesheet", :href => "/#{current_theme}/application.css")
end

#include_theme_jsObject



10
11
12
# File 'lib/vitae/server/helpers.rb', line 10

def include_theme_js
  (:script, nil, :type => "text/javascript", :src => "/#{current_theme}/application.js")
end


14
15
16
17
18
# File 'lib/vitae/server/helpers.rb', line 14

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



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

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