Module: ActionView::Helpers::TagHelper
Overview
This is poor man’s Builder for the rare cases where you need to programmatically make tags but can’t use Builder.
Instance Method Summary collapse
-
#content_tag(name, content, options = {}) ⇒ Object
Examples: *
content_tag("p", "Hello world!") => <p>Hello world!</p>
*content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") =>
<div class="strong"><p>Hello world!</p></div>
. -
#tag(name, options = {}, open = false) ⇒ Object
Examples: *
tag("br") => <br />
*tag("input", { "type" => "text"}) => <input type="text" />
.
Instance Method Details
#content_tag(name, content, options = {}) ⇒ Object
Examples:
-
content_tag("p", "Hello world!") => <p>Hello world!</p>
-
content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") =>
<div class="strong"><p>Hello world!</p></div>
21 22 23 |
# File 'lib/action_view/helpers/tag_helper.rb', line 21 def content_tag(name, content, = {}) "<#{name}#{()}>#{content}</#{name}>" end |
#tag(name, options = {}, open = false) ⇒ Object
Examples:
-
tag("br") => <br />
-
tag("input", { "type" => "text"}) => <input type="text" />
13 14 15 |
# File 'lib/action_view/helpers/tag_helper.rb', line 13 def tag(name, = {}, open = false) "<#{name}#{()}" + (open ? ">" : " />") end |