From 9327bfe44c4ca32a52137589013d20f4561dbd67 Mon Sep 17 00:00:00 2001 From: Reiner Dieterich Date: Fri, 20 Aug 2010 19:34:04 +0200 Subject: [PATCH] added methods fb_concat and fb_html_safe -> use concat or not, depending on rails version -> use html_safe when available --- lib/facebooker2/rails/helpers/javascript.rb | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/facebooker2/rails/helpers/javascript.rb b/lib/facebooker2/rails/helpers/javascript.rb index 83d530c..7cbf84d 100644 --- a/lib/facebooker2/rails/helpers/javascript.rb +++ b/lib/facebooker2/rails/helpers/javascript.rb @@ -2,6 +2,22 @@ module Facebooker2 module Rails module Helpers module Javascript + def fb_concat(str) + if ::Rails::VERSION::STRING.to_i > 2 + str + else + concat(str) + end + end + + def fb_html_safe(str) + if str.respond_to?(:html_safe) + str.html_safe + else + str + end + end + def fb_connect_async_js(app_id=Facebooker2.app_id,options={},&proc) opts = Hash.new(true).merge!(options) cookie = opts[:cookie] @@ -32,11 +48,7 @@ module Facebooker2 }()); JAVASCRIPT - if ::Rails::VERSION::STRING.to_i > 2 - js.html_safe - else - block_given? ? concat(js) : js - end + fb_html_safe(block_given? ? fb_concat(js) : js) end end end