Module: Helpers
- Included in:
- Vitae::Nodes::Node
- Defined in:
- lib/vitae/server/helpers.rb
Instance Method Summary collapse
- #content_tag(*args, &block) ⇒ Object
- #current_theme ⇒ Object
- #include_theme_css ⇒ Object
- #include_theme_js ⇒ Object
- #link_to(text, *args) ⇒ Object
- #tag(*args, &block) ⇒ Object
Instance Method Details
#content_tag(*args, &block) ⇒ Object
20 21 22 23 |
# File 'lib/vitae/server/helpers.rb', line 20 def content_tag(*args, &block) args.last[:double_tag] = true if args.last.is_a?(Hash) tag(*args, &block) end |
#current_theme ⇒ Object
2 3 4 |
# File 'lib/vitae/server/helpers.rb', line 2 def current_theme @cv && @cv.theme || "default" end |
#include_theme_css ⇒ Object
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_js ⇒ Object
10 11 12 |
# File 'lib/vitae/server/helpers.rb', line 10 def include_theme_js content_tag(:script, nil, :type => "text/javascript", :src => "/#{current_theme}/application.js") end |
#link_to(text, *args) ⇒ Object
14 15 16 17 18 |
# File 'lib/vitae/server/helpers.rb', line 14 def link_to(text, *args) = args.last.is_a?(Hash) ? args.pop : {} link = args.first || text.split(/\s+/).join('_').downcase content_tag :a, text, .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 = args.last.is_a?(Hash) ? args.pop : {} double_tag = .delete(:double_tag) attrs = if .size>0 " "+.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 |