Module: Shareable::ActionViewExtension
- Defined in:
- lib/shareable/helpers/action_view_extension.rb
Overview
Helpers
Instance Method Summary collapse
- #html_attributes(attributes, opts = {}) ⇒ Object
-
#output_once(name, &block) ⇒ Object
credit to elektronaut.no/.
-
#render_shareable(options = {}, &block) ⇒ Object
A helper that renders social links <%= render_shareable [options] %>.
Instance Method Details
#html_attributes(attributes, opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/shareable/helpers/action_view_extension.rb', line 6 def html_attributes(attributes, opts={}) opts = { :data => false }.merge(opts) prefix = opts[:data] ? 'data-' : '' attributes.map { |(k, v)| if v.present? %{#{prefix}#{k.to_s.camelize(:lower)}="#{html_escape( v )}"}.html_safe end }.compact.join( " " ).html_safe end |
#output_once(name, &block) ⇒ Object
credit to elektronaut.no/
36 37 38 39 40 41 42 |
# File 'lib/shareable/helpers/action_view_extension.rb', line 36 def output_once(name, &block) #:nodoc: @output_once_blocks ||= [] unless @output_once_blocks.include?(name) @output_once_blocks << name capture(&block) end end |
#render_shareable(options = {}, &block) ⇒ Object
A helper that renders social links
<%= render_shareable [options] %>
21 22 23 24 |
# File 'lib/shareable/helpers/action_view_extension.rb', line 21 def render_shareable( = {}, &block) = Shareable::Helpers::SocialButtons.new self, () .to_s end |