class Locomotive::Steam::Liquid::Tags::SEO::Base

Public Instance Methods

render(context) click to toggle source
# File lib/locomotive/steam/liquid/tags/seo.rb, line 9
def render(context)
  self.render_title(context) +
  self.render_metadata(context)
end

Protected Instance Methods

metadata_object(context) click to toggle source
# File lib/locomotive/steam/liquid/tags/seo.rb, line 43
def metadata_object(context)
  context['content_entry'] || context['page']
end
render_metadata(context) click to toggle source
# File lib/locomotive/steam/liquid/tags/seo.rb, line 25
def render_metadata(context)
  %{
    <meta name="description" content="#{self.value_for(:meta_description, context)}">
    <meta name="keywords" content="#{self.value_for(:meta_keywords, context)}">
  }
end
render_title(context) click to toggle source
# File lib/locomotive/steam/liquid/tags/seo.rb, line 16
def render_title(context)
  title = self.value_for(:seo_title, context)
  title = context['site'].name if title.blank?

  %{
    <title>#{title}</title>
  }
end
sanitized_string(string) click to toggle source

Removes whitespace and quote charactets from the input

# File lib/locomotive/steam/liquid/tags/seo.rb, line 33
def sanitized_string(string)
  string ? string.strip.gsub(/"/, '') : ''
end
value_for(attribute, context) click to toggle source
# File lib/locomotive/steam/liquid/tags/seo.rb, line 37
def value_for(attribute, context)
  object = self.metadata_object(context)
  value = object.try(attribute.to_sym).blank? ? context['site'].send(attribute.to_sym) : object.send(attribute.to_sym)
  self.sanitized_string(value)
end