Module: LoyalShareButtons::Helper

Defined in:
lib/loyal_share_buttons/helper.rb

Instance Method Summary collapse

Instance Method Details

#loyal_share_buttons_tag(title = "", opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/loyal_share_buttons/helper.rb', line 4

def loyal_share_buttons_tag(title = "", opts = {})
  rel = opts[:rel]
  html = []
  html << "<div class='loyal_share_buttons' data-title='#{title}' data-img='#{opts[:image]}'>"

  ::LoyalShareButtons.config.allow_sites.each do |_name|
    _name = _name.downcase
    name = I18n.t("views.loyal_share_buttons.#{_name}")
    link_title = I18n.t "views.loyal_share_buttons.share_to", :name => name
    html << link_to("","javascript:;", :rel => "nofollow #{rel}",
                    "data-site" => _name,
                    :class => "loyal_share_buttons-#{_name}",
                    :onclick => "return LoyalShareButtons.share(this);",
                    :title => h(link_title))
  end
  html << "</div>"
  raw html.join("\n")
end