Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

facebook suppport

  • Loading branch information...
commit aec5d01c44c9989678bafe2454d8fbf5d466f4ee 1 parent 1b6cac6
jspaper authored June 16, 2012
10  README.markdown
Source Rendered
@@ -32,6 +32,16 @@ The output html will be like this:
32 32
     <meta name="description" content="default description" />
33 33
     <meta name="keywords" content="my,keyword" />
34 34
 
  35
+Facebook support
  36
+
  37
+    <% set_meta(:title=>"my title", :facebook=>{:title=>"album title test", :type=>"og_mysite_dev:album"}) %>
  38
+
  39
+The output html will be like this:
  40
+
  41
+    <meta name="title" content="my title"/>
  42
+    <meta property="og:title" content="album title test"/>
  43
+    <meta property="og:type" content="og_mysite_dev:album"/>
  44
+
35 45
 
36 46
 Author
37 47
 ======
10  lib/meta_on_rails/view_helpers.rb
@@ -6,8 +6,14 @@ def set_meta(meta = {})
6 6
 
7 7
     def display_meta(default = {})
8 8
       meta = default.merge(@meta||{}).reject{|k,v|v.blank?}
9  
-      output = meta.map do |key,value|
10  
-        %Q[<meta name="#{key}" content="#{normalize(value)}"/>]
  9
+      output=meta.map do |key, value|
  10
+        if key==:facebook
  11
+          value.map do |property, content|
  12
+            %Q[<meta property="og:#{property}" content="#{normalize(content)}"/>]
  13
+          end.join("\n")
  14
+        else
  15
+          %Q[<meta name="#{key}" content="#{normalize(value)}"/>]
  16
+        end
11 17
       end.join("\n")
12 18
       Rails.version.to_i > 2 ? ActiveSupport::SafeBuffer.new(output) : output
13 19
     end

0 notes on commit aec5d01

Please sign in to comment.
Something went wrong with that request. Please try again.