123456789_123456789_123456789_123456789_123456789_

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, options)

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

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="[&quot;Chicago&quot;,&quot;IL&quot;]"></div>

In addition to :data and :aria, nest sub-attribute hashes for any keys:

tag.button "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 &amp; shut.png">

tag.img src: 'open & shut.png', escape: false
### => <img src="open & shut.png">

The tag builder respectsHTML5 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">

<button <%= 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

Instance Method Summary

Constructor Details

.new(view_context) ⇒ TagBuilder

This method is for internal use only.
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1508

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 1661

def method_missing(called, *args, escape: true, **options, &block)
  name = called.name.dasherize

  TagHelper.ensure_valid_html5_tag_name(name)

  tag_string(name, *args, options, escape: escape, &block)
end

Class Method Details

.define_element(name, code_generator:, method_name: name)

This method is for internal use only.
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1342

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)

This method is for internal use only.
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1362

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)

This method is for internal use only.
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1353

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 443

rdoc_method :method: a

#abbr(content = nil, escape: true, **options, &block)

Renders a abbr HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 452

rdoc_method :method: abbr

#address(content = nil, escape: true, **options, &block)

Renders an address HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 461

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 317

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 326

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 335

rdoc_method :method: animate_transform

#append_boolean_tag_option(output, key) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1606

def append_boolean_tag_option(output, key)
  key = Symbol === key ? key.name : key.to_s
  output << key
  output << "=\""
  output << key
  output << "\""
end

#append_prefix_tag_option(output, prefix, key, value, escape) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1649

def append_prefix_tag_option(output, 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
  append_tag_option(output, key, value, escape)
end

#append_tag_option(output, key, value, escape) (private)

Appends a single attribute to #output without allocating an intermediate string per attribute.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1622

def append_tag_option(output, key, value, escape)
  key = Symbol === key ? key.name : key.to_s
  key = ERB::Util.xml_name_escape(key) if escape

  case value
  when Array, Hash
    value = TagHelper.build_tag_values(value) if key == "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('"', "&quot;") if value.include?('"')

  output << key
  output << "=\""
  output << value
  output << "\""
end

#area(content = nil, **options, &block)

Renders a void area HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 191

rdoc_method :method: area

#article(content = nil, escape: true, **options, &block)

Renders an article HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 470

rdoc_method :method: article

#aside(content = nil, escape: true, **options, &block)

Renders an aside HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 479

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">

<button <%= tag.attributes id: "call_to_action", disabled: false, aria: { expanded: false } %>>Get Started!</button>
#### => <button id="call_to_action" aria-expanded="false">Get Started!</button>
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1527

def attributes(attributes)
  tag_options(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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 488

rdoc_method :method: audio

#b(content = nil, escape: true, **options, &block)

Renders a b HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 497

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 200

rdoc_method :method: base

#bdi(content = nil, escape: true, **options, &block)

Renders a bdi HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 506

rdoc_method :method: bdi

#bdo(content = nil, escape: true, **options, &block)

Renders a bdo HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 515

rdoc_method :method: bdo

#blockquote(content = nil, escape: true, **options, &block)

Renders a blockquote HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 524

rdoc_method :method: blockquote

#body(content = nil, escape: true, **options, &block)

Renders a body HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 533

rdoc_method :method: body

#boolean_tag_option(key) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1600

def boolean_tag_option(key)
  output = +""
  append_boolean_tag_option(output, key)
  output
end

#br(content = nil, escape: true, **options, &block)

Renders a void br HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 209

rdoc_method :method: br

#button(content = nil, escape: true, **options, &block)

Renders a button HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 542

rdoc_method :method: button

#canvas(content = nil, escape: true, **options, &block)

Renders a canvas HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 551

rdoc_method :method: canvas

#caption(content = nil, escape: true, **options, &block)

Renders a caption HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 560

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 344

rdoc_method :method: circle

#cite(content = nil, escape: true, **options, &block)

Renders a cite HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 569

rdoc_method :method: cite

#code(content = nil, escape: true, **options, &block)

Renders a code HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 578

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 218

rdoc_method :method: col

#colgroup(content = nil, escape: true, **options, &block)

Renders a colgroup HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 587

rdoc_method :method: colgroup

#content_tag_string(name, content, options, escape = true)

This method is for internal use only.
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1531

def (name, content, options, escape = true) # :nodoc:
  tag_options = tag_options(options, escape) if options

  if escape && content.present?
    content = ERB::Util.unwrapped_html_escape(content)
  end
  "<#{name}#{tag_options}>#{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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 596

rdoc_method :method: data

#datalist(content = nil, escape: true, **options, &block)

Renders a datalist HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 605

rdoc_method :method: datalist

#dd(content = nil, escape: true, **options, &block)

Renders a dd HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 614

rdoc_method :method: dd

#del(content = nil, escape: true, **options, &block)

Renders a del HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 623

rdoc_method :method: del

#details(content = nil, escape: true, **options, &block)

Renders a details HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 632

rdoc_method :method: details

#dfn(content = nil, escape: true, **options, &block)

Renders a dfn HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 641

rdoc_method :method: dfn

#dialog(content = nil, escape: true, **options, &block)

Renders a dialog HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 650

rdoc_method :method: dialog

#div(content = nil, escape: true, **options, &block)

Renders a div HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 659

rdoc_method :method: div

#dl(content = nil, escape: true, **options, &block)

Renders a dl HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 668

rdoc_method :method: dl

#dt(content = nil, escape: true, **options, &block)

Renders a dt HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 677

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 353

rdoc_method :method: ellipse

#em(content = nil, escape: true, **options, &block)

Renders an em HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 686

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 227

rdoc_method :method: embed

#fieldset(content = nil, escape: true, **options, &block)

Renders a fieldset HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 695

rdoc_method :method: fieldset

#figcaption(content = nil, escape: true, **options, &block)

Renders a figcaption HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 704

rdoc_method :method: figcaption

#figure(content = nil, escape: true, **options, &block)

Renders a figure HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 713

rdoc_method :method: figure

#form(content = nil, escape: true, **options, &block)

Renders a form HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 731

rdoc_method :method: form

#h1(content = nil, escape: true, **options, &block)

Renders an h1 HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 740

rdoc_method :method: h1

#h2(content = nil, escape: true, **options, &block)

Renders an h2 HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 749

rdoc_method :method: h2

#h3(content = nil, escape: true, **options, &block)

Renders an h3 HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 758

rdoc_method :method: h3

#h4(content = nil, escape: true, **options, &block)

Renders an h4 HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 767

rdoc_method :method: h4

#h5(content = nil, escape: true, **options, &block)

Renders an h5 HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 776

rdoc_method :method: h5

#h6(content = nil, escape: true, **options, &block)

Renders an h6 HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 785

rdoc_method :method: h6

#head(content = nil, escape: true, **options, &block)

Renders a head HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 794

rdoc_method :method: head

#header(content = nil, escape: true, **options, &block)

Renders a header HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 803

rdoc_method :method: header

#hgroup(content = nil, escape: true, **options, &block)

Renders an hgroup HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 812

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 236

rdoc_method :method: hr

#html(content = nil, escape: true, **options, &block)

Renders an html HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 821

rdoc_method :method: html

#i(content = nil, escape: true, **options, &block)

Renders an i HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 830

rdoc_method :method: i

#iframe(content = nil, escape: true, **options, &block)

Renders an iframe HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 839

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 245

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 254

rdoc_method :method: input

#ins(content = nil, escape: true, **options, &block)

Renders an ins HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 848

rdoc_method :method: ins

#kbd(content = nil, escape: true, **options, &block)

Renders a kbd HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 857

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 263

rdoc_method :method: keygen

#label(content = nil, escape: true, **options, &block)

Renders a label HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 866

rdoc_method :method: label

#legend(content = nil, escape: true, **options, &block)

Renders a legend HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 875

rdoc_method :method: legend

#li(content = nil, escape: true, **options, &block)

Renders an li HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 884

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 362

rdoc_method :method: line

#main(content = nil, escape: true, **options, &block)

Renders a main HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 893

rdoc_method :method: main

#map(content = nil, escape: true, **options, &block)

Renders a map HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 902

rdoc_method :method: map

#mark(content = nil, escape: true, **options, &block)

Renders a mark HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 911

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 281

rdoc_method :method: meta

#meter(content = nil, escape: true, **options, &block)

Renders a meter HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 929

rdoc_method :method: meter

#noscript(content = nil, escape: true, **options, &block)

Renders a noscript HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 947

rdoc_method :method: noscript

#object(content = nil, escape: true, **options, &block)

Renders an object HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 956

rdoc_method :method: object

#ol(content = nil, escape: true, **options, &block)

Renders an ol HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 965

rdoc_method :method: ol

#optgroup(content = nil, escape: true, **options, &block)

Renders an optgroup HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 974

rdoc_method :method: optgroup

#option(content = nil, escape: true, **options, &block)

Renders an option HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 983

rdoc_method :method: option

#output(content = nil, escape: true, **options, &block)

Renders an output HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 992

rdoc_method :method: output

#p(content = nil, escape: true, **options, &block)

Renders a p HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1001

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 371

rdoc_method :method: path

#picture(content = nil, escape: true, **options, &block)

Renders a picture HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1010

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 380

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 389

rdoc_method :method: polyline

#portal(content = nil, escape: true, **options, &block)

Renders a portal HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1019

rdoc_method :method: portal

#pre(content = nil, escape: true, **options, &block)

Renders a pre HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1028

rdoc_method :method: pre

#prefix_tag_option(prefix, key, value, escape) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1643

def prefix_tag_option(prefix, key, value, escape)
  output = +""
  append_prefix_tag_option(output, prefix, key, value, escape)
  output
end

#progress(content = nil, escape: true, **options, &block)

Renders a progress HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1037

rdoc_method :method: progress

#q(content = nil, escape: true, **options, &block)

Renders a q HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1046

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 398

rdoc_method :method: rect

#respond_to_missing?(*args) ⇒ Boolean (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1657

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1055

rdoc_method :method: rp

#rt(content = nil, escape: true, **options, &block)

Renders an rt HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1064

rdoc_method :method: rt

#ruby(content = nil, escape: true, **options, &block)

Renders a ruby HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1073

rdoc_method :method: ruby

#s(content = nil, escape: true, **options, &block)

Renders an s HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1082

rdoc_method :method: s

#samp(content = nil, escape: true, **options, &block)

Renders a samp HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1091

rdoc_method :method: samp

#script(content = nil, escape: true, **options, &block)

Renders a script HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1100

rdoc_method :method: script

#search(content = nil, escape: true, **options, &block)

Renders a search HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1109

rdoc_method :method: search

#section(content = nil, escape: true, **options, &block)

Renders a section HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1118

rdoc_method :method: section

#select(content = nil, escape: true, **options, &block)

Renders a select HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1127

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 1596

def self_closing_tag_string(name, options, escape = true, tag_suffix = " />")
  "<#{name}#{tag_options(options, 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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 407

rdoc_method :method: set

#slot(content = nil, escape: true, **options, &block)

Renders a slot HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1136

rdoc_method :method: slot

#small(content = nil, escape: true, **options, &block)

Renders a small HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1145

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 290

rdoc_method :method: source

#span(content = nil, escape: true, **options, &block)

Renders a span HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1154

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 416

rdoc_method :method: stop

#strong(content = nil, escape: true, **options, &block)

Renders a strong HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1163

rdoc_method :method: strong

#style(content = nil, escape: true, **options, &block)

Renders a style HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1172

rdoc_method :method: style

#sub(content = nil, escape: true, **options, &block)

Renders a sub HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1181

rdoc_method :method: sub

#summary(content = nil, escape: true, **options, &block)

Renders a summary HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1190

rdoc_method :method: summary

#sup(content = nil, escape: true, **options, &block)

Renders a sup HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1199

rdoc_method :method: sup

#table(content = nil, escape: true, **options, &block)

Renders a table HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1208

rdoc_method :method: table

#tag_option(key, value, escape) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1614

def tag_option(key, value, escape)
  output = +""
  append_tag_option(output, key, value, escape)
  output
end

#tag_options(options, escape = true)

This method is for internal use only.
[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1540

def tag_options(options, escape = true) # :nodoc:
  return if options.blank?
  output = +""
  sep    = " "
  options.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
        append_prefix_tag_option(output, 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
        append_prefix_tag_option(output, key, k, v, escape)
      end
    elsif type == :boolean
      if value
        output << sep
        append_boolean_tag_option(output, key)
      end
    elsif !value.nil?
      output << sep
      append_tag_option(output, 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 1586

def tag_string(name, content = nil, options, escape: true, &block)
  if content && block_given?
    content += @view_context.capture(self, &block)
  elsif block_given?
    content = @view_context.capture(self, &block)
  end

  (name, content, options, escape)
end

#tbody(content = nil, escape: true, **options, &block)

Renders a tbody HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1217

rdoc_method :method: tbody

#td(content = nil, escape: true, **options, &block)

Renders a td HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1226

rdoc_method :method: td

#template(content = nil, escape: true, **options, &block)

Renders a template HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1235

rdoc_method :method: template

#textarea(content = nil, escape: true, **options, &block)

Renders a textarea HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1244

rdoc_method :method: textarea

#tfoot(content = nil, escape: true, **options, &block)

Renders a tfoot HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1253

rdoc_method :method: tfoot

#th(content = nil, escape: true, **options, &block)

Renders a th HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1262

rdoc_method :method: th

#thead(content = nil, escape: true, **options, &block)

Renders a thead HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1271

rdoc_method :method: thead

#time(content = nil, escape: true, **options, &block)

Renders a time HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1280

rdoc_method :method: time

#title(content = nil, escape: true, **options, &block)

Renders a title HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1289

rdoc_method :method: title

#tr(content = nil, escape: true, **options, &block)

Renders a tr HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1298

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 299

rdoc_method :method: track

#u(content = nil, escape: true, **options, &block)

Renders a u HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1307

rdoc_method :method: u

#ul(content = nil, escape: true, **options, &block)

Renders a ul HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1316

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 425

rdoc_method :method: use

#var(content = nil, escape: true, **options, &block)

Renders a var HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1325

rdoc_method :method: var

#video(content = nil, escape: true, **options, &block)

Renders a video HTML element

Refer to the class documentation for more details.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 1342

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 434

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.

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tag_helper.rb', line 308

rdoc_method :method: wbr