Module: Wikilink::Converter::LinkHelper
- Included in:
- Namespace, Sites::RubyChina
- Defined in:
- lib/wikilink/converter/utils.rb
Instance Method Summary collapse
Instance Method Details
#link_to(name, url, attributes = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/wikilink/converter/utils.rb', line 26 def link_to(name, url, attributes = {}) attributes[:class] = Array(attributes[:class]).flatten.join(' ').split.uniq.join(' ') attributes.delete(:class) if attributes[:class].empty? attributes = attributes.inject('') do |memo, (key, value)| memo + key.to_s + '="' + CGI.escape_html(value) + '" ' end "<a #{attributes}href=\"#{CGI.escape_html url}\">#{CGI.escape_html name}</a>" end |