lib/apotomo/widget/javascript_methods.rb in apotomo-1.1.0.rc1 vs lib/apotomo/widget/javascript_methods.rb in apotomo-1.1.0
- old
+ new
@@ -1,7 +1,12 @@
module Apotomo
module JavascriptMethods
+ # Returns the escaped script.
+ def escape_js(script)
+ Apotomo.js_generator.escape(script)
+ end
+
# Wraps the rendered content in a replace statement targeted at your +Apotomo.js_framework+ setting.
# Use +:selector+ to change the selector.
#
# Example:
#
@@ -26,14 +31,14 @@
wrap_in_javascript_for(:update, *args)
end
private
def wrap_in_javascript_for(mode, *args)
- content = render(*args)
- options = args.first.is_a?(::Hash) ? args.shift : {}
+ selector = args.first.is_a?(String) ? args.shift : false
+ content = render(*args)
- options[:selector] ?
- Apotomo.js_generator.send(mode, options[:selector], content) : # replace(:twitter)
- Apotomo.js_generator.send("#{mode}_id", name, content) # replace_id(:twitter)
+ selector ?
+ Apotomo.js_generator.send(mode, selector, content) : # replace(:twitter)
+ Apotomo.js_generator.send("#{mode}_id", name, content) # replace_id(:twitter)
end
end
end