Module: Viewaide::Helpers::LinkHelper
- Included in:
- Viewaide::Helpers
- Defined in:
- lib/viewaide/helpers/link_helper.rb
Instance Method Summary collapse
-
#link_button(*args, &block) ⇒ String
Generates a link that’s able to be styled like a button.
-
#link_to_email(email_address, *args) ⇒ String
Generates a link to an email address.
Instance Method Details
#link_button(*args, &block) ⇒ String
Generates a link that’s able to be styled like a button. This functions exactly like Rails’ #link_to but wraps the link text in a span and assigns a class of “btn”
20 21 22 23 24 25 |
# File 'lib/viewaide/helpers/link_helper.rb', line 20 def (*args, &block) doc = Hpricot(link_to(*args, &block)) doc.at("a").inner_html = "<span>#{doc.at("a").inner_html}</span>" (doc/:a).add_class("btn") doc.to_html end |
#link_to_email(email_address, *args) ⇒ String
Generates a link to an email address. This functions exactly like Rails’ #link_to but changes the href to include “mailto:”
46 47 48 49 50 51 |
# File 'lib/viewaide/helpers/link_helper.rb', line 46 def link_to_email(email_address, *args) = args. link = args.first.is_a?(String) ? h(args.first) : email_address return link if email_address.blank? link_to link, "mailto:#{email_address}", end |