Permalink
Browse files

facebook suppport

  • Loading branch information...
jspaper committed Jun 16, 2012
1 parent 1b6cac6 commit aec5d01c44c9989678bafe2454d8fbf5d466f4ee
Showing with 18 additions and 2 deletions.
  1. +10 −0 README.markdown
  2. +8 −2 lib/meta_on_rails/view_helpers.rb
View
@@ -32,6 +32,16 @@ The output html will be like this:
<meta name="description" content="default description" />
<meta name="keywords" content="my,keyword" />
+Facebook support
+
+ <% set_meta(:title=>"my title", :facebook=>{:title=>"album title test", :type=>"og_mysite_dev:album"}) %>
+
+The output html will be like this:
+
+ <meta name="title" content="my title"/>
+ <meta property="og:title" content="album title test"/>
+ <meta property="og:type" content="og_mysite_dev:album"/>
+
Author
======
@@ -6,8 +6,14 @@ def set_meta(meta = {})
def display_meta(default = {})
meta = default.merge(@meta||{}).reject{|k,v|v.blank?}
- output = meta.map do |key,value|
- %Q[<meta name="#{key}" content="#{normalize(value)}"/>]
+ output=meta.map do |key, value|
+ if key==:facebook
+ value.map do |property, content|
+ %Q[<meta property="og:#{property}" content="#{normalize(content)}"/>]
+ end.join("\n")
+ else
+ %Q[<meta name="#{key}" content="#{normalize(value)}"/>]
+ end
end.join("\n")
Rails.version.to_i > 2 ? ActiveSupport::SafeBuffer.new(output) : output
end

0 comments on commit aec5d01

Please sign in to comment.