Repository: rails/rails
File: actionview/lib/action_view/renderer/partial_renderer.rb (Ruby)

Code before:
  # equivalent to:
  #
  #   <%= render partial: "account", locals: { account: @buyer } %>
  #
  # With the <tt>:as</tt> option we can specify a different name for said local variable. For example, if we
  # wanted it to be +user+ instead of +account+ we'd do:
  #
  #   <%= render partial: "account", object: @buyer, as: 'user' %>
  #
  # This is equivalent to
  #
  #   <%= render partial: "account", locals: { user: @buyer } %>
  #
  # == \Rendering variants of a partial
  #
  # The <tt>:variants</tt> option can be used to render a different template variant of a partial. For instance:
  #
  #   <%= render partial: "account", variants: :mobile %>
  #
  # This will render <tt>_account.html+mobile.erb</tt>. This option also accepts multiple variants
  # like so:
  #
  #   <%= render partial: "account", variants: [:desktop, :mobile] %>
  #
  # This will render <tt>_account.html+desktop.erb</tt>, <tt>_account.html+mobile.erb</tt>
  # and with <tt>:desktop</tt> will render the original <tt>_account.html.erb</tt>.
  #
  # == \Rendering a collection of partials
  #
  # The example of partial use describes a familiar pattern where a template needs to iterate over an array and
  # render a sub template for each of the elements. This pattern has been implemented as a single method that
  # accepts an array and renders a partial by the same name as the elements contained within. So the three-lined
  # example in "Using partials" can be rewritten with a single line:
  #
  #   <%= render partial: "ad", collection: @advertisements %>
  #
  # This will render <tt>advertiser/_ad.html.erb</tt> and pass the local variable +ad+ to the template for display. An
  # iteration object will automatically be made available to the template with a name of the form
  # +partial_name_iteration+. The iteration object has knowledge about which index the current object has in
  # the collection and the total size of the collection. The iteration object also has two convenience methods,
  # +first?+ and +last?+. In the case of the example above, the template would be fed +ad_iteration+.
  # For backwards compatibility the +partial_name_counter+ is still present and is mapped to the iteration's
  # +index+ method.
  #
  # The <tt>:as</tt> option may be used when rendering partials.
  #
  # You can specify a partial to be rendered between elements via the <tt>:spacer_template</tt> option.
  # The following example will render <tt>advertiser/_ad_divider.html.erb</tt> between each ad partial:
  #
  #   <%= render partial: "ad", collection: @advertisements, spacer_template: "ad_divider" %>
  #

Review comment (suggestion):
This part is a bit unclear to me.
Maybe copy this from the guides?
https://edgeguides.rubyonrails.org/layouts_and_rendering.html#the-variants-option

```suggestion
  # This will look for the following templates and render the first one that exists:
  # * <tt>_account.html+desktop.erb</tt>
  # * <tt>_account.html+mobile.erb</tt>
  # * <tt>_account.html.erb</tt>
```

Code after:
  # equivalent to:
  #
  #   <%= render partial: "account", locals: { account: @buyer } %>
  #
  # With the <tt>:as</tt> option we can specify a different name for said local variable. For example, if we
  # wanted it to be +user+ instead of +account+ we'd do:
  #
  #   <%= render partial: "account", object: @buyer, as: 'user' %>
  #
  # This is equivalent to
  #
  #   <%= render partial: "account", locals: { user: @buyer } %>
  #
  # == \Rendering variants of a partial
  #
  # The <tt>:variants</tt> option can be used to render a different template variant of a partial. For instance:
  #
  #   <%= render partial: "account", variants: :mobile %>
  #
  # This will render <tt>_account.html+mobile.erb</tt>. This option also accepts multiple variants
  # like so:
  #
  #   <%= render partial: "account", variants: [:desktop, :mobile] %>
  #
  # This will look for the following templates and render the first one that exists:
  # * <tt>_account.html+desktop.erb</tt>
  # * <tt>_account.html+mobile.erb</tt>
  # * <tt>_account.html.erb</tt>
  #
  # == \Rendering a collection of partials
  #
  # The example of partial use describes a familiar pattern where a template needs to iterate over an array and
  # render a sub template for each of the elements. This pattern has been implemented as a single method that
  # accepts an array and renders a partial by the same name as the elements contained within. So the three-lined
  # example in "Using partials" can be rewritten with a single line:
  #
  #   <%= render partial: "ad", collection: @advertisements %>
  #
  # This will render <tt>advertiser/_ad.html.erb</tt> and pass the local variable +ad+ to the template for display. An
  # iteration object will automatically be made available to the template with a name of the form
  # +partial_name_iteration+. The iteration object has knowledge about which index the current object has in
  # the collection and the total size of the collection. The iteration object also has two convenience methods,
  # +first?+ and +last?+. In the case of the example above, the template would be fed +ad_iteration+.
  # For backwards compatibility the +partial_name_counter+ is still present and is mapped to the iteration's
  # +index+ method.
  #
  # The <tt>:as</tt> option may be used when rendering partials.
  #
  # You can specify a partial to be rendered between elements via the <tt>:spacer_template</tt> option.
  # The following example will render <tt>advertiser/_ad_divider.html.erb</tt> between each ad partial:
  #