lib/namba/helpers/action_view_extension.rb in namba-1.1.0 vs lib/namba/helpers/action_view_extension.rb in namba-1.2.0
- old
+ new
@@ -1,14 +1,15 @@
module Namba
module ActionViewExtension
- def namba_comments(component_name, component_id)
- html = []
- html << content_tag(:div, "", :id => "namba-comments")
- # html << javascript_include_tag("http://api.namba.#{Namba::Config.options[:locale]}/nb.js.php")
- html << javascript_include_tag("http://api.namba.kg/nb.js.php")
- html << javascript_tag("NB.insert(\"comments\", \"namba-comments\", {component: \"#{component_name}\", componentId: #{component_id}});")
- html.join("\n").html_safe
+ %w(comments share).map do |key|
+ define_method(:"namba_#{key}") do |component_name, component_id|
+ html = []
+ html << content_tag(:div, "", :id => "namba-#{key}")
+ html << javascript_include_tag("http://api.namba.kg/nb.js.php")
+ html << javascript_tag("NB.insert(\"#{key}\", \"namba-#{key}\", {component: \"#{component_name}\", componentId: #{component_id}});")
+ html.join("\n").html_safe
+ end
end
end
end
\ No newline at end of file