End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
CGI::HtmlExtension#a
a(href = "") { || ... }
lib/cgi/html.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/cgi/html.rb, line 97
def a(href = "") # :yield:
attributes = if href.kind_of?(String)
{ "HREF" => href }
else
href
end
super(attributes)
end
Generate an Anchor element as a string.
href can either be a string, giving the URL for the HREF attribute, or it can be a hash of the element’s attributes.
The body of the element is the string returned by the no-argument block passed in.
Example
a("http://www.example.com") { "Example" } # => "<A HREF=\"http://www.example.com\">Example</A>" a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" } # => "<A HREF=\"http://www.example.com\" TARGET=\"_top\">Example</A>"