Class: ActionView::Helpers::TagHelper::TagBuilder
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | actionview/lib/action_view/helpers/tag_helper.rb |
Overview
Action View Tag Builder
Returns an HTML tag.
Builds HTML5 compliant tags with a tag proxy. Every tag can be built with:
tag.<tag name>(optional content, )
where tag name can be e.g. #br, #div, #section, #article, or any tag really.
To render an HTML custom element, replace the - in the tag's name
with _. For example:
tag.turbo_frame id: "a-turbo-frame"
# => <turbo-frame id="a-turbo-frame"></turbo-frame>
Passing content
::ActionView::Helpers::Tags can pass content to embed within it:
tag.h1 'All titles fit to print' # => <h1>All titles fit to print</h1>
tag.div tag.p('Hello world!') # => <div><p>Hello world!</p></div>
Content can also be captured with a block, which is useful in templates:
<%= tag.p do %>
The next great American novel starts here.
<% end %>
# => <p>The next great American novel starts here.</p>
Options
Use symbol keyed options to add attributes to the generated tag.
tag.section class: %w( kitties puppies )
# => <section class="kitties puppies"></section>
tag.section id: dom_id(@post)
# => <section id="<generated dom id>"></section>
Pass true for any attributes that can render with no values, like disabled and readonly.
tag.input type: 'text', disabled: true
# => <input type="text" disabled="disabled">
HTML5 data-* and aria-* attributes can be set with a
single #data or aria key pointing to a hash of sub-attributes.
To play nicely with JavaScript conventions, sub-attributes are dasherized.
tag.article data: { user_id: 123 }
# => <article data-user-id="123"></article>
Thus data-user-id can be accessed as dataset.userId.
::Data attribute values are encoded to JSON, with the exception of strings, symbols, and
BigDecimals.
This may come in handy when using jQuery's HTML5-aware .data()
from 1.4.3.
tag.div data: { city_state: %w( Chicago IL ) }
# => <div data-city-state="["Chicago","IL"]"></div>
In addition to :data and :aria, nest sub-attribute hashes for any keys:
tag. "POST to /clicked", hx: { post: "/clicked", swap: :outerHTML }
# => <button hx-post="/clicked" hx-swap="outerHTML">POST to /clicked</button>
The generated tag names and attributes are escaped by default. This can be disabled using
escape.
tag.img src: 'open & shut.png'
# => <img src="open & shut.png">
tag.img src: 'open & shut.png', escape: false
# => <img src="open & shut.png">
The tag builder respects HTML5 void elements if no content is passed, and omits closing tags for those elements.
# A standard element:
tag.div # => <div></div>
# A void element:
tag.br # => <br>
Note that when using the block form options should be wrapped in parenthesis.
<%= tag.a(href: "/about", class: "font-bold") do %>
About the author
<% end %>
# => <a href="/about" class="font-bold">About the author</a>
Building HTML attributes
Transforms a ::Hash into HTML attributes, ready to be interpolated into
::ERB. Includes or omits boolean attributes based on their truthiness.
Transforms keys nested within
aria: or data: objects into aria- and data-
prefixed attributes:
<input <%= tag.attributes(type: :text, aria: { label: "Search" }) %>>
# => <input type="text" aria-label="Search">
< <%= tag.attributes id: "call-to-action", disabled: false, aria: { expanded: false } %> class="primary">Get Started!</button>
# => <button id="call-to-action" aria-expanded="false" class="primary">Get Started!</button>
Class Method Summary
- .define_element(name, code_generator:, method_name: name) Internal use only
- .define_self_closing_element(name, code_generator:, method_name: name) Internal use only
- .define_void_element(name, code_generator:, method_name: name) Internal use only
- .new(view_context) ⇒ TagBuilder constructor Internal use only
Instance Method Summary
-
#a(content = nil, escape: true, **options, &block)
Renders an a HTML element.
-
#abbr(content = nil, escape: true, **options, &block)
Renders a abbr HTML element.
-
#address(content = nil, escape: true, **options, &block)
Renders an address HTML element.
-
#animate(content = nil, escape: true, **options, &block)
Renders a self-closing animate HTML element.
-
#animate_motion(content = nil, escape: true, **options, &block)
Renders a self-closing animateMotion HTML element.
-
#animate_transform(content = nil, escape: true, **options, &block)
Renders a self-closing animateTransform HTML element.
-
#area(content = nil, **options, &block)
Renders a void area HTML element.
-
#article(content = nil, escape: true, **options, &block)
Renders an article HTML element.
-
#aside(content = nil, escape: true, **options, &block)
Renders an aside HTML element.
- #attributes(attributes)
-
#audio(content = nil, escape: true, **options, &block)
Renders an audio HTML element.
-
#b(content = nil, escape: true, **options, &block)
Renders a b HTML element.
-
#base(content = nil, escape: true, **options, &block)
Renders a void base HTML element.
-
#bdi(content = nil, escape: true, **options, &block)
Renders a bdi HTML element.
-
#bdo(content = nil, escape: true, **options, &block)
Renders a bdo HTML element.
-
#blockquote(content = nil, escape: true, **options, &block)
Renders a blockquote HTML element.
-
#body(content = nil, escape: true, **options, &block)
Renders a body HTML element.
-
#br(content = nil, escape: true, **options, &block)
Renders a void br HTML element.
-
#button(content = nil, escape: true, **options, &block)
Renders a button HTML element.
-
#canvas(content = nil, escape: true, **options, &block)
Renders a canvas HTML element.
-
#caption(content = nil, escape: true, **options, &block)
Renders a caption HTML element.
-
#circle(content = nil, escape: true, **options, &block)
Renders a self-closing circle HTML element.
-
#cite(content = nil, escape: true, **options, &block)
Renders a cite HTML element.
-
#code(content = nil, escape: true, **options, &block)
Renders a code HTML element.
-
#col(content = nil, escape: true, **options, &block)
Renders a void col HTML element.
-
#colgroup(content = nil, escape: true, **options, &block)
Renders a colgroup HTML element.
-
#data(content = nil, escape: true, **options, &block)
Renders a data HTML element.
-
#datalist(content = nil, escape: true, **options, &block)
Renders a datalist HTML element.
-
#dd(content = nil, escape: true, **options, &block)
Renders a dd HTML element.
-
#del(content = nil, escape: true, **options, &block)
Renders a del HTML element.
-
#details(content = nil, escape: true, **options, &block)
Renders a details HTML element.
-
#dfn(content = nil, escape: true, **options, &block)
Renders a dfn HTML element.
-
#dialog(content = nil, escape: true, **options, &block)
Renders a dialog HTML element.
-
#div(content = nil, escape: true, **options, &block)
Renders a div HTML element.
-
#dl(content = nil, escape: true, **options, &block)
Renders a dl HTML element.
-
#dt(content = nil, escape: true, **options, &block)
Renders a dt HTML element.
-
#ellipse(content = nil, escape: true, **options, &block)
Renders a self-closing ellipse HTML element.
-
#em(content = nil, escape: true, **options, &block)
Renders an em HTML element.
-
#embed(content = nil, escape: true, **options, &block)
Renders a void embed HTML element.
-
#fieldset(content = nil, escape: true, **options, &block)
Renders a fieldset HTML element.
-
#figcaption(content = nil, escape: true, **options, &block)
Renders a figcaption HTML element.
-
#figure(content = nil, escape: true, **options, &block)
Renders a figure HTML element.
-
#footer(content = nil, escape: true, **options, &block)
Renders a footer HTML element.
-
#form(content = nil, escape: true, **options, &block)
Renders a form HTML element.
-
#h1(content = nil, escape: true, **options, &block)
Renders an h1 HTML element.
-
#h2(content = nil, escape: true, **options, &block)
Renders an h2 HTML element.
-
#h3(content = nil, escape: true, **options, &block)
Renders an h3 HTML element.
-
#h4(content = nil, escape: true, **options, &block)
Renders an h4 HTML element.
-
#h5(content = nil, escape: true, **options, &block)
Renders an h5 HTML element.
-
#h6(content = nil, escape: true, **options, &block)
Renders an h6 HTML element.
-
#head(content = nil, escape: true, **options, &block)
Renders a head HTML element.
-
#header(content = nil, escape: true, **options, &block)
Renders a header HTML element.
-
#hgroup(content = nil, escape: true, **options, &block)
Renders an hgroup HTML element.
-
#hr(content = nil, escape: true, **options, &block)
Renders a void hr HTML element.
-
#html(content = nil, escape: true, **options, &block)
Renders an html HTML element.
-
#i(content = nil, escape: true, **options, &block)
Renders an i HTML element.
-
#iframe(content = nil, escape: true, **options, &block)
Renders an iframe HTML element.
-
#img(content = nil, escape: true, **options, &block)
Renders a void img HTML element.
-
#input(content = nil, escape: true, **options, &block)
Renders a void input HTML element.
-
#ins(content = nil, escape: true, **options, &block)
Renders an ins HTML element.
-
#kbd(content = nil, escape: true, **options, &block)
Renders a kbd HTML element.
-
#keygen(content = nil, escape: true, **options, &block)
Renders a void keygen HTML element.
-
#label(content = nil, escape: true, **options, &block)
Renders a label HTML element.
-
#legend(content = nil, escape: true, **options, &block)
Renders a legend HTML element.
-
#li(content = nil, escape: true, **options, &block)
Renders an li HTML element.
-
#line(content = nil, escape: true, **options, &block)
Renders a self-closing line HTML element.
-
#link(content = nil, escape: true, **options, &block)
Renders a void link HTML element.
-
#main(content = nil, escape: true, **options, &block)
Renders a main HTML element.
-
#map(content = nil, escape: true, **options, &block)
Renders a map HTML element.
-
#mark(content = nil, escape: true, **options, &block)
Renders a mark HTML element.
-
#menu(content = nil, escape: true, **options, &block)
Renders a menu HTML element.
-
#meta(content = nil, escape: true, **options, &block)
Renders a void meta HTML element.
-
#meter(content = nil, escape: true, **options, &block)
Renders a meter HTML element.
-
#nav(content = nil, escape: true, **options, &block)
Renders a nav HTML element.
-
#noscript(content = nil, escape: true, **options, &block)
Renders a noscript HTML element.
-
#object(content = nil, escape: true, **options, &block)
Renders an object HTML element.
-
#ol(content = nil, escape: true, **options, &block)
Renders an ol HTML element.
-
#optgroup(content = nil, escape: true, **options, &block)
Renders an optgroup HTML element.
-
#option(content = nil, escape: true, **options, &block)
Renders an option HTML element.
-
#output(content = nil, escape: true, **options, &block)
Renders an output HTML element.
-
#p(content = nil, escape: true, **options, &block)
Renders a p HTML element.
-
#path(content = nil, escape: true, **options, &block)
Renders a self-closing path HTML element.
-
#picture(content = nil, escape: true, **options, &block)
Renders a picture HTML element.
-
#polygon(content = nil, escape: true, **options, &block)
Renders a self-closing polygon HTML element.
-
#polyline(content = nil, escape: true, **options, &block)
Renders a self-closing polyline HTML element.
-
#portal(content = nil, escape: true, **options, &block)
Renders a portal HTML element.
-
#pre(content = nil, escape: true, **options, &block)
Renders a pre HTML element.
-
#progress(content = nil, escape: true, **options, &block)
Renders a progress HTML element.
-
#q(content = nil, escape: true, **options, &block)
Renders a q HTML element.
-
#rect(content = nil, escape: true, **options, &block)
Renders a self-closing rect HTML element.
-
#rp(content = nil, escape: true, **options, &block)
Renders an rp HTML element.
-
#rt(content = nil, escape: true, **options, &block)
Renders an rt HTML element.
-
#ruby(content = nil, escape: true, **options, &block)
Renders a ruby HTML element.
-
#s(content = nil, escape: true, **options, &block)
Renders an s HTML element.
-
#samp(content = nil, escape: true, **options, &block)
Renders a samp HTML element.
-
#script(content = nil, escape: true, **options, &block)
Renders a script HTML element.
-
#search(content = nil, escape: true, **options, &block)
Renders a search HTML element.
-
#section(content = nil, escape: true, **options, &block)
Renders a section HTML element.
-
#select(content = nil, escape: true, **options, &block)
Renders a select HTML element.
-
#set(content = nil, escape: true, **options, &block)
Renders a self-closing set HTML element.
-
#slot(content = nil, escape: true, **options, &block)
Renders a slot HTML element.
-
#small(content = nil, escape: true, **options, &block)
Renders a small HTML element.
-
#source(content = nil, escape: true, **options, &block)
Renders a void source HTML element.
-
#span(content = nil, escape: true, **options, &block)
Renders a span HTML element.
-
#stop(content = nil, escape: true, **options, &block)
Renders a self-closing stop HTML element.
-
#strong(content = nil, escape: true, **options, &block)
Renders a strong HTML element.
-
#style(content = nil, escape: true, **options, &block)
Renders a style HTML element.
-
#sub(content = nil, escape: true, **options, &block)
Renders a sub HTML element.
-
#summary(content = nil, escape: true, **options, &block)
Renders a summary HTML element.
-
#sup(content = nil, escape: true, **options, &block)
Renders a sup HTML element.
-
#table(content = nil, escape: true, **options, &block)
Renders a table HTML element.
-
#tbody(content = nil, escape: true, **options, &block)
Renders a tbody HTML element.
-
#td(content = nil, escape: true, **options, &block)
Renders a td HTML element.
-
#template(content = nil, escape: true, **options, &block)
Renders a template HTML element.
-
#textarea(content = nil, escape: true, **options, &block)
Renders a textarea HTML element.
-
#tfoot(content = nil, escape: true, **options, &block)
Renders a tfoot HTML element.
-
#th(content = nil, escape: true, **options, &block)
Renders a th HTML element.
-
#thead(content = nil, escape: true, **options, &block)
Renders a thead HTML element.
-
#time(content = nil, escape: true, **options, &block)
Renders a time HTML element.
-
#title(content = nil, escape: true, **options, &block)
Renders a title HTML element.
-
#tr(content = nil, escape: true, **options, &block)
Renders a tr HTML element.
-
#track(content = nil, escape: true, **options, &block)
Renders a void track HTML element.
-
#u(content = nil, escape: true, **options, &block)
Renders a u HTML element.
-
#ul(content = nil, escape: true, **options, &block)
Renders a ul HTML element.
-
#use(content = nil, escape: true, **options, &block)
Renders a self-closing use HTML element.
-
#var(content = nil, escape: true, **options, &block)
Renders a var HTML element.
-
#video(content = nil, escape: true, **options, &block)
Renders a video HTML element.
-
#view(content = nil, escape: true, **options, &block)
Renders a self-closing view HTML element.
-
#wbr(content = nil, escape: true, **options, &block)
Renders a void wbr HTML element.
- #boolean_tag_option(key) private
- #method_missing(called, *args, escape: true, **options, &block) private
- #prefix_tag_option(prefix, key, value, escape) private
- #respond_to_missing?(*args) ⇒ Boolean private
- #self_closing_tag_string(name, options, escape = true, tag_suffix = " />") private
- #tag_option(key, value, escape) private
- #tag_string(name, content = nil, options, escape: true, &block) private
- #content_tag_string(name, content, options, escape = true) Internal use only
- #tag_options(options, escape = true) Internal use only
Constructor Details
.new(view_context) ⇒ TagBuilder
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1479
def initialize(view_context) # :nodoc: @view_context = view_context end
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(called, *args, escape: true, **options, &block) (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1602
def method_missing(called, *args, escape: true, **, &block) name = called.name.dasherize TagHelper.ensure_valid_html5_tag_name(name) tag_string(name, *args, , escape: escape, &block) end
Class Method Details
.define_element(name, code_generator:, method_name: name)
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1313
def self.define_element(name, code_generator:, method_name: name) # :nodoc: return if method_defined?(name) code_generator.class_eval do |batch| batch << "\n" << "def #{method_name}(content = nil, escape: true, **options, &block)" << " tag_string(#{name.inspect}, content, options, escape: escape, &block)" << "end" end end
.define_self_closing_element(name, code_generator:, method_name: name)
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1333
def self.define_self_closing_element(name, code_generator:, method_name: name) # :nodoc: code_generator.class_eval do |batch| batch << "\n" << "def #{method_name}(content = nil, escape: true, **options, &block)" << " if content || block" << " tag_string(#{name.inspect}, content, options, escape: escape, &block)" << " else" << " self_closing_tag_string(#{name.inspect}, options, escape)" << " end" << "end" end end
.define_void_element(name, code_generator:, method_name: name)
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1324
def self.define_void_element(name, code_generator:, method_name: name) # :nodoc: code_generator.class_eval do |batch| batch << "\n" << "def #{method_name}(escape: true, **options, &block)" << " self_closing_tag_string(#{name.inspect}, options, escape, '>')" << "end" end end
Instance Method Details
#a(content = nil, escape: true, **options, &block)
Renders an a HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 414
rdoc_method :method: a
#abbr(content = nil, escape: true, **options, &block)
Renders a abbr HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 423
rdoc_method :method: abbr
#address(content = nil, escape: true, **options, &block)
Renders an address HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 432
rdoc_method :method: address
#animate(content = nil, escape: true, **options, &block)
Renders a self-closing animate HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 288
rdoc_method :method: animate
#animate_motion(content = nil, escape: true, **options, &block)
Renders a self-closing animateMotion HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 297
rdoc_method :method: animate_motion
#animate_transform(content = nil, escape: true, **options, &block)
Renders a self-closing animateTransform HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 306
rdoc_method :method: animate_transform
#area(content = nil, **options, &block)
Renders a void area HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 162
rdoc_method :method: area
#article(content = nil, escape: true, **options, &block)
Renders an article HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 441
rdoc_method :method: article
#aside(content = nil, escape: true, **options, &block)
Renders an aside HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 450
rdoc_method :method: aside
#attributes(attributes)
Transforms a ::Hash into HTML Attributes, ready to be interpolated into
::ERB.
Includes or omits boolean attributes based on their truthiness.
Transforms keys nested within
aria: or data: objects into aria- and data-
prefixed attributes:
<input <%= tag.attributes(type: :text, aria: { label: "Search" }) %> >
# => <input type="text" aria-label="Search">
< <%= tag.attributes id: "call_to_action", disabled: false, aria: { expanded: false } %>>Get Started!</button>
# => < id="call_to_action" aria-="false">Get Started!</button>
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1496
def attributes(attributes) (attributes.to_h).to_s.strip.html_safe end
#audio(content = nil, escape: true, **options, &block)
Renders an audio HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 459
rdoc_method :method: audio
#b(content = nil, escape: true, **options, &block)
Renders a b HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 468
rdoc_method :method: b
#base(content = nil, escape: true, **options, &block)
Renders a void base HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 171
rdoc_method :method: base
#bdi(content = nil, escape: true, **options, &block)
Renders a bdi HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 477
rdoc_method :method: bdi
#bdo(content = nil, escape: true, **options, &block)
Renders a bdo HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 486
rdoc_method :method: bdo
#blockquote(content = nil, escape: true, **options, &block)
Renders a blockquote HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 495
rdoc_method :method: blockquote
#body(content = nil, escape: true, **options, &block)
Renders a body HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 504
rdoc_method :method: body
#boolean_tag_option(key) (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1569
def boolean_tag_option(key) %(#{key}="#{key}") end
#br(content = nil, escape: true, **options, &block)
Renders a void br HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 180
rdoc_method :method: br
#button(content = nil, escape: true, **options, &block)
Renders a button HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 513
rdoc_method :method:
#canvas(content = nil, escape: true, **options, &block)
Renders a canvas HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 522
rdoc_method :method: canvas
#caption(content = nil, escape: true, **options, &block)
Renders a caption HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 531
rdoc_method :method: caption
#circle(content = nil, escape: true, **options, &block)
Renders a self-closing circle HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 315
rdoc_method :method: circle
#cite(content = nil, escape: true, **options, &block)
Renders a cite HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 540
rdoc_method :method: cite
#code(content = nil, escape: true, **options, &block)
Renders a code HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 549
rdoc_method :method: code
#col(content = nil, escape: true, **options, &block)
Renders a void col HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 189
rdoc_method :method: col
#colgroup(content = nil, escape: true, **options, &block)
Renders a colgroup HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 558
rdoc_method :method: colgroup
#content_tag_string(name, content, options, escape = true)
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1500
def content_tag_string(name, content, , escape = true) # :nodoc: = (, escape) if if escape && content.present? content = ERB::Util.unwrapped_html_escape(content) end "<#{name}#{}>#{PRE_CONTENT_STRINGS[name]}#{content}</#{name}>".html_safe end
#data(content = nil, escape: true, **options, &block)
Renders a data HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 567
rdoc_method :method: data
#datalist(content = nil, escape: true, **options, &block)
Renders a datalist HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 576
rdoc_method :method: datalist
#dd(content = nil, escape: true, **options, &block)
Renders a dd HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 585
rdoc_method :method: dd
#del(content = nil, escape: true, **options, &block)
Renders a del HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 594
rdoc_method :method: del
#details(content = nil, escape: true, **options, &block)
Renders a details HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 603
rdoc_method :method: details
#dfn(content = nil, escape: true, **options, &block)
Renders a dfn HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 612
rdoc_method :method: dfn
#dialog(content = nil, escape: true, **options, &block)
Renders a dialog HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 621
rdoc_method :method: dialog
#div(content = nil, escape: true, **options, &block)
Renders a div HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 630
rdoc_method :method: div
#dl(content = nil, escape: true, **options, &block)
Renders a dl HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 639
rdoc_method :method: dl
#dt(content = nil, escape: true, **options, &block)
Renders a dt HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 648
rdoc_method :method: dt
#ellipse(content = nil, escape: true, **options, &block)
Renders a self-closing ellipse HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 324
rdoc_method :method: ellipse
#em(content = nil, escape: true, **options, &block)
Renders an em HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 657
rdoc_method :method: em
#embed(content = nil, escape: true, **options, &block)
Renders a void embed HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 198
rdoc_method :method:
#fieldset(content = nil, escape: true, **options, &block)
Renders a fieldset HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 666
rdoc_method :method: fieldset
#figcaption(content = nil, escape: true, **options, &block)
Renders a figcaption HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 675
rdoc_method :method: figcaption
#figure(content = nil, escape: true, **options, &block)
Renders a figure HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 684
rdoc_method :method: figure
#form(content = nil, escape: true, **options, &block)
Renders a form HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 702
rdoc_method :method: form
#h1(content = nil, escape: true, **options, &block)
Renders an h1 HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 711
rdoc_method :method: h1
#h2(content = nil, escape: true, **options, &block)
Renders an h2 HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 720
rdoc_method :method: h2
#h3(content = nil, escape: true, **options, &block)
Renders an h3 HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 729
rdoc_method :method: h3
#h4(content = nil, escape: true, **options, &block)
Renders an h4 HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 738
rdoc_method :method: h4
#h5(content = nil, escape: true, **options, &block)
Renders an h5 HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 747
rdoc_method :method: h5
#h6(content = nil, escape: true, **options, &block)
Renders an h6 HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 756
rdoc_method :method: h6
#head(content = nil, escape: true, **options, &block)
Renders a head HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 765
rdoc_method :method: head
#header(content = nil, escape: true, **options, &block)
Renders a header HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 774
rdoc_method :method: header
#hgroup(content = nil, escape: true, **options, &block)
Renders an hgroup HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 783
rdoc_method :method: hgroup
#hr(content = nil, escape: true, **options, &block)
Renders a void hr HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 207
rdoc_method :method: hr
#html(content = nil, escape: true, **options, &block)
Renders an html HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 792
rdoc_method :method: html
#i(content = nil, escape: true, **options, &block)
Renders an i HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 801
rdoc_method :method: i
#iframe(content = nil, escape: true, **options, &block)
Renders an iframe HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 810
rdoc_method :method: iframe
#img(content = nil, escape: true, **options, &block)
Renders a void img HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 216
rdoc_method :method: img
#input(content = nil, escape: true, **options, &block)
Renders a void input HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 225
rdoc_method :method: input
#ins(content = nil, escape: true, **options, &block)
Renders an ins HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 819
rdoc_method :method: ins
#kbd(content = nil, escape: true, **options, &block)
Renders a kbd HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 828
rdoc_method :method: kbd
#keygen(content = nil, escape: true, **options, &block)
Renders a void keygen HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 234
rdoc_method :method: keygen
#label(content = nil, escape: true, **options, &block)
Renders a label HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 837
rdoc_method :method: label
#legend(content = nil, escape: true, **options, &block)
Renders a legend HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 846
rdoc_method :method: legend
#li(content = nil, escape: true, **options, &block)
Renders an li HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 855
rdoc_method :method: li
#line(content = nil, escape: true, **options, &block)
Renders a self-closing line HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 333
rdoc_method :method: line
#link(content = nil, escape: true, **options, &block)
Renders a void link HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 243
rdoc_method :method: link
#main(content = nil, escape: true, **options, &block)
Renders a main HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 864
rdoc_method :method: main
#map(content = nil, escape: true, **options, &block)
Renders a map HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 873
rdoc_method :method: map
#mark(content = nil, escape: true, **options, &block)
Renders a mark HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 882
rdoc_method :method: mark
#meta(content = nil, escape: true, **options, &block)
Renders a void meta HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 252
rdoc_method :method:
#meter(content = nil, escape: true, **options, &block)
Renders a meter HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 900
rdoc_method :method: meter
#noscript(content = nil, escape: true, **options, &block)
Renders a noscript HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 918
rdoc_method :method: noscript
#object(content = nil, escape: true, **options, &block)
Renders an object HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 927
rdoc_method :method: object
#ol(content = nil, escape: true, **options, &block)
Renders an ol HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 936
rdoc_method :method: ol
#optgroup(content = nil, escape: true, **options, &block)
Renders an optgroup HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 945
rdoc_method :method: optgroup
#option(content = nil, escape: true, **options, &block)
Renders an option HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 954
rdoc_method :method: option
#output(content = nil, escape: true, **options, &block)
Renders an output HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 963
rdoc_method :method: output
#p(content = nil, escape: true, **options, &block)
Renders a p HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 972
rdoc_method :method: p
#path(content = nil, escape: true, **options, &block)
Renders a self-closing path HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 342
rdoc_method :method: path
#picture(content = nil, escape: true, **options, &block)
Renders a picture HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 981
rdoc_method :method: picture
#polygon(content = nil, escape: true, **options, &block)
Renders a self-closing polygon HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 351
rdoc_method :method: polygon
#polyline(content = nil, escape: true, **options, &block)
Renders a self-closing polyline HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 360
rdoc_method :method: polyline
#portal(content = nil, escape: true, **options, &block)
Renders a portal HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 990
rdoc_method :method: portal
#pre(content = nil, escape: true, **options, &block)
Renders a pre HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 999
rdoc_method :method: pre
#prefix_tag_option(prefix, key, value, escape) (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1590
def prefix_tag_option(prefix, key, value, escape) key = "#{prefix}-#{key.to_s.dasherize}" unless value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(BigDecimal) value = value.to_json end tag_option(key, value, escape) end
#progress(content = nil, escape: true, **options, &block)
Renders a progress HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1008
rdoc_method :method: progress
#q(content = nil, escape: true, **options, &block)
Renders a q HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1017
rdoc_method :method: q
#rect(content = nil, escape: true, **options, &block)
Renders a self-closing rect HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 369
rdoc_method :method: rect
#respond_to_missing?(*args) ⇒ Boolean (private)
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1598
def respond_to_missing?(*args) true end
#rp(content = nil, escape: true, **options, &block)
Renders an rp HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1026
rdoc_method :method: rp
#rt(content = nil, escape: true, **options, &block)
Renders an rt HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1035
rdoc_method :method: rt
#ruby(content = nil, escape: true, **options, &block)
Renders a ruby HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1044
rdoc_method :method: ruby
#s(content = nil, escape: true, **options, &block)
Renders an s HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1053
rdoc_method :method: s
#samp(content = nil, escape: true, **options, &block)
Renders a samp HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1062
rdoc_method :method: samp
#script(content = nil, escape: true, **options, &block)
Renders a script HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1071
rdoc_method :method: script
#search(content = nil, escape: true, **options, &block)
Renders a search HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1080
rdoc_method :method: search
#section(content = nil, escape: true, **options, &block)
Renders a section HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1089
rdoc_method :method: section
#select(content = nil, escape: true, **options, &block)
Renders a select HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1098
rdoc_method :method: select
#self_closing_tag_string(name, options, escape = true, tag_suffix = " />") (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1565
def self_closing_tag_string(name, , escape = true, tag_suffix = " />") "<#{name}#{(, escape)}#{tag_suffix}".html_safe end
#set(content = nil, escape: true, **options, &block)
Renders a self-closing set HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 378
rdoc_method :method: set
#slot(content = nil, escape: true, **options, &block)
Renders a slot HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1107
rdoc_method :method: slot
#small(content = nil, escape: true, **options, &block)
Renders a small HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1116
rdoc_method :method: small
#source(content = nil, escape: true, **options, &block)
Renders a void source HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 261
rdoc_method :method: source
#span(content = nil, escape: true, **options, &block)
Renders a span HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1125
rdoc_method :method: span
#stop(content = nil, escape: true, **options, &block)
Renders a self-closing stop HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 387
rdoc_method :method: stop
#strong(content = nil, escape: true, **options, &block)
Renders a strong HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1134
rdoc_method :method: strong
#style(content = nil, escape: true, **options, &block)
Renders a style HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1143
rdoc_method :method: style
#sub(content = nil, escape: true, **options, &block)
Renders a sub HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1152
rdoc_method :method: sub
#summary(content = nil, escape: true, **options, &block)
Renders a summary HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1161
rdoc_method :method: summary
#sup(content = nil, escape: true, **options, &block)
Renders a sup HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1170
rdoc_method :method: sup
#table(content = nil, escape: true, **options, &block)
Renders a table HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1179
rdoc_method :method: table
#tag_option(key, value, escape) (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1573
def tag_option(key, value, escape) key = ERB::Util.xml_name_escape(key) if escape case value when Array, Hash value = TagHelper.build_tag_values(value) if key.to_s == "class" value = escape ? @view_context.safe_join(value, " ") : value.join(" ") when Regexp value = escape ? ERB::Util.unwrapped_html_escape(value.source) : value.source else value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s end value = value.gsub('"', """) if value.include?('"') %(#{key}="#{value}") end
#tag_options(options, escape = true)
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1509
def (, escape = true) # :nodoc: return if .blank? output = +"" sep = " " .each_pair do |key, value| next if key.blank? type = TAG_TYPES[key] if type != :aria && type != :class && value.is_a?(Hash) value.each_pair do |k, v| next if k.blank? || v.nil? output << sep output << prefix_tag_option(key, k, v, escape) end elsif type == :aria && value.is_a?(Hash) value.each_pair do |k, v| next if k.blank? || v.nil? case v when Array, Hash tokens = TagHelper.build_tag_values(v) next if tokens.none? v = @view_context.safe_join(tokens, " ") else v = v.to_s end output << sep output << prefix_tag_option(key, k, v, escape) end elsif type == :boolean if value output << sep output << boolean_tag_option(key) end elsif !value.nil? output << sep output << tag_option(key, value, escape) end end output unless output.empty? end
#tag_string(name, content = nil, options, escape: true, &block) (private)
[ GitHub ]# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1555
def tag_string(name, content = nil, , escape: true, &block) if content && block_given? content += @view_context.capture(self, &block) elsif block_given? content = @view_context.capture(self, &block) end content_tag_string(name, content, , escape) end
#tbody(content = nil, escape: true, **options, &block)
Renders a tbody HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1188
rdoc_method :method: tbody
#td(content = nil, escape: true, **options, &block)
Renders a td HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1197
rdoc_method :method: td
#template(content = nil, escape: true, **options, &block)
Renders a template HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1206
rdoc_method :method: template
#textarea(content = nil, escape: true, **options, &block)
Renders a textarea HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1215
rdoc_method :method: textarea
#tfoot(content = nil, escape: true, **options, &block)
Renders a tfoot HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1224
rdoc_method :method: tfoot
#th(content = nil, escape: true, **options, &block)
Renders a th HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1233
rdoc_method :method: th
#thead(content = nil, escape: true, **options, &block)
Renders a thead HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1242
rdoc_method :method: thead
#time(content = nil, escape: true, **options, &block)
Renders a time HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1251
rdoc_method :method: time
#title(content = nil, escape: true, **options, &block)
Renders a title HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1260
rdoc_method :method: title
#tr(content = nil, escape: true, **options, &block)
Renders a tr HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1269
rdoc_method :method: tr
#track(content = nil, escape: true, **options, &block)
Renders a void track HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 270
rdoc_method :method: track
#u(content = nil, escape: true, **options, &block)
Renders a u HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1278
rdoc_method :method: u
#ul(content = nil, escape: true, **options, &block)
Renders a ul HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1287
rdoc_method :method: ul
#use(content = nil, escape: true, **options, &block)
Renders a self-closing use HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 396
rdoc_method :method: use
#var(content = nil, escape: true, **options, &block)
Renders a var HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1296
rdoc_method :method: var
#video(content = nil, escape: true, **options, &block)
Renders a video HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1313
RDoc directive :method: video
#view(content = nil, escape: true, **options, &block)
Renders a self-closing view HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 405
rdoc_method :method: view
#wbr(content = nil, escape: true, **options, &block)
Renders a void wbr HTML element
Refer to the class documentation for more details.
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 279
rdoc_method :method: wbr