class WrapIt::Link

HTML link element

You can specify link by `link`, `href` or `url` option or by first String argument. Also includes {TextContainer} module, so you can specify link body with `text` or `body` option or by second String argument or inside block.

@example usage

link = WrapIt::Link.new(template, 'http://some.url', 'text')
link.render # => '<a href="http://some.url">test</a>'
link = WrapIt::Link.new(template, link: 'http://some.url', text: 'text')
link.render # => '<a href="http://some.url">test</a>'
link = WrapIt::Link.new(template, 'text', link: http://some.url')
link.render # => '<a href="http://some.url">test</a>'

@example in template

<%= link 'http://some.url' do %>text<% end %>

@author Alexey Ovchinnikov <alexiss@cybernetlab.ru>

Public Instance Methods

href() click to toggle source

Retrieves current link

@return [String] link

# File lib/wrap_it/link.rb, line 41
def href
  html_attr[:href]
end
href=(value) click to toggle source

Sets link @param value [String] link

@return [String] setted link

# File lib/wrap_it/link.rb, line 50
def href=(value)
  if value.is_a?(Hash)
    WrapIt.rails? || fail(
      ArgumentError,
      'Hash links supported only in Rails env'
    )
    value = @template.url_for(value)
  end
  value.is_a?(String) || fail(ArgumentError, 'Wrong link type')
  html_attr[:href] = value
end
Also aliased as: link=, url=
url=(value)
Alias for: href=