This is poor man’s Builder for the rare cases where you need to programmatically make tags but can’t use Builder.
Methods
Included Modules
- ERB::Util
Public Instance methods
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>
[ show source ]
# File vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb, line 21
21: def content_tag(name, content, options = {})
22: "<#{name}#{tag_options(options)}>#{content}</#{name}>"
23: end
Examples:
- tag("br") => <br />
- tag("input", { "type" => "text"}) => <input type="text" />
[ show source ]
# File vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb, line 13
13: def tag(name, options = {}, open = false)
14: "<#{name}#{tag_options(options)}" + (open ? ">" : " />")
15: end