Module: Anchored::Linker
Instance Method Summary collapse
- #auto_link(text, options = {}, &block) ⇒ Object
-
#remove_target_if_local(href, domain, options) ⇒ Object
remove_target_if_local(“same.com/x”, “same.com”, target: “_blank”) => <a href=“same.com/x”>same.com/x</a>.
Instance Method Details
#auto_link(text, options = {}, &block) ⇒ Object
7 8 9 10 |
# File 'lib/anchored/linker.rb', line 7 def auto_link(text, = {}, &block) return "" if text.to_s.empty? auto_link_urls(text, , &block) end |
#remove_target_if_local(href, domain, options) ⇒ Object
remove_target_if_local(“same.com/x”, “same.com”, target: “_blank”)
> <a href=“same.com/x”>same.com/x</a>
remove_target_if_local(“same.com/x”, “different.com”, target: “_blank”)
> <a href=“same.com/x” target=“_blank”>same.com/x</a>
modifies options in place
19 20 21 22 |
# File 'lib/anchored/linker.rb', line 19 def remove_target_if_local(href, domain, ) return unless [:target] .delete(:target) if href.include?("//#{domain}") end |