Module: Plate::MetaHelper
- Included in:
- View
- Defined in:
- lib/plate/helpers/meta_helper.rb
Overview
Methods related to the meta-data of a page
Instance Method Summary collapse
-
#description? ⇒ Boolean
Is there a description available for this page?.
-
#keywords ⇒ Object
Sanitize keywords output into a comma separated list string.
-
#keywords? ⇒ Boolean
Are there keywords available on this page?.
-
#meta_description_tag ⇒ Object
Returns a description meta tag if there is a description available for this page.
-
#meta_keywords_tag ⇒ Object
Returns a keywords meta tag if there are keywords for this page.
-
#meta_tags([tags...], options) ⇒ Object
Output the standard meta tags (keywords and description) to a page.
-
#title? ⇒ Boolean
Does this page have a title?.
Instance Method Details
#description? ⇒ Boolean
Is there a description available for this page?
5 6 7 |
# File 'lib/plate/helpers/meta_helper.rb', line 5 def description? !page.description.to_s.blank? end |
#keywords ⇒ Object
Sanitize keywords output into a comma separated list string
10 11 12 |
# File 'lib/plate/helpers/meta_helper.rb', line 10 def keywords page.keywords.join(", ") end |
#keywords? ⇒ Boolean
Are there keywords available on this page?
15 16 17 |
# File 'lib/plate/helpers/meta_helper.rb', line 15 def keywords? page.keywords.length > 0 end |
#meta_description_tag ⇒ Object
Returns a description meta tag if there is a description available for this page.
21 22 23 |
# File 'lib/plate/helpers/meta_helper.rb', line 21 def %Q(<meta name="description" content="#{description}">) if description? end |
#meta_keywords_tag ⇒ Object
Returns a keywords meta tag if there are keywords for this page.
26 27 28 |
# File 'lib/plate/helpers/meta_helper.rb', line 26 def %Q(<meta name="keywords" content="#{keywords}">) if keywords? end |
#meta_tags([tags...], options) ⇒ Object
Output the standard meta tags (keywords and description) to a page. Omits any tags with blank data.
Optionally pass in a list of which tags to display.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/plate/helpers/meta_helper.rb', line 49 def (*args) = args. = .reverse_merge({ :joiner => "\n" }) = args.length > 0 ? args : %w( description keywords ) result = [] .each do |tag| result << self.send("meta_#{tag}_tag") if self.respond_to?("meta_#{tag}_tag") end result.join([:joiner]).strip end |
#title? ⇒ Boolean
Does this page have a title?
67 68 69 |
# File 'lib/plate/helpers/meta_helper.rb', line 67 def title? !page.title.to_s.blank? end |