added methods fb_concat and fb_html_safe

-> use concat or not, depending on rails version
  -> use html_safe when available
This commit is contained in:
Reiner Dieterich 2010-08-20 19:34:04 +02:00
parent 5ea3d5459b
commit 9327bfe44c

View File

@ -2,6 +2,22 @@ module Facebooker2
module Rails module Rails
module Helpers module Helpers
module Javascript 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) def fb_connect_async_js(app_id=Facebooker2.app_id,options={},&proc)
opts = Hash.new(true).merge!(options) opts = Hash.new(true).merge!(options)
cookie = opts[:cookie] cookie = opts[:cookie]
@ -32,11 +48,7 @@ module Facebooker2
}()); }());
</script> </script>
JAVASCRIPT JAVASCRIPT
if ::Rails::VERSION::STRING.to_i > 2 fb_html_safe(block_given? ? fb_concat(js) : js)
js.html_safe
else
block_given? ? concat(js) : js
end
end end
end end
end end