Module: Nazca::ViewHelpers

Defined in:
lib/nazca/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#canonical(href) ⇒ Object



33
34
35
# File 'lib/nazca/view_helpers.rb', line 33

def canonical(href)
  tag!(:canonical => true)
end

#description(d) ⇒ Object



18
19
20
21
# File 'lib/nazca/view_helpers.rb', line 18

def description(d)
  tag!(:description => normalize(d))
  d
end

#keywords(k) ⇒ Object



13
14
15
16
# File 'lib/nazca/view_helpers.rb', line 13

def keywords(k)
  tag!(:keywords => normalize(k))
  k
end

#meta_tags(site_name, options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nazca/view_helpers.rb', line 38

def meta_tags(site_name, options = {})
  result = ""
  @_nazca_tags ||= {}

  options[:separator] ||= "|"
  options[:reversed] ||= false
  
  options.merge!(@_nazca_tags)
  
  if options[:title].to_s.length > 0 # maybe use ActiveSupport and .present? method
    title = [site_name, options[:separator], options[:title]]
  else
    title = [site_name]
  end
  
  title.reverse! if options[:reverse]
  result << (:title, title.join(' ').html_safe)

  result << tag(:meta, :name => :description, :content => options[:description]) if options[:description]
  result << tag(:meta, :name => :keywords, :content => options[:keywords]) if options[:keywords]
  return result.html_safe
end

#nofollow(nofollow) ⇒ Object



29
30
31
# File 'lib/nazca/view_helpers.rb', line 29

def nofollow(nofollow)
  tag!(:nofollow => true)
end

#noindexObject



24
25
26
# File 'lib/nazca/view_helpers.rb', line 24

def noindex
  tag!(:noindex => true)
end

#tag!(tags = {}) ⇒ Object



3
4
5
6
# File 'lib/nazca/view_helpers.rb', line 3

def tag!(tags = {})
  @_nazca_tags ||= {}
  @_nazca_tags.merge!(tags)
end

#title(t) ⇒ Object



8
9
10
11
# File 'lib/nazca/view_helpers.rb', line 8

def title(t)
  tag!(:title => normalize(t))
  t
end