mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update guide for the counter variable when rendering with the as:
option
[ci skip]
This commit is contained in:
parent
d234dd677a
commit
8d5a2c4da1
1 changed files with 1 additions and 1 deletions
|
@ -1266,7 +1266,7 @@ You can also pass in arbitrary local variables to any partial you are rendering
|
||||||
|
|
||||||
In this case, the partial will have access to a local variable `title` with the value "Products Page".
|
In this case, the partial will have access to a local variable `title` with the value "Products Page".
|
||||||
|
|
||||||
TIP: Rails also makes a counter variable available within a partial called by the collection, named after the title of the partial followed by `_counter`. For example, when rendering a collection `@products` the partial `_product.html.erb` can access the variable `product_counter` which indexes the number of times it has been rendered within the enclosing view.
|
TIP: Rails also makes a counter variable available within a partial called by the collection, named after the title of the partial followed by `_counter`. For example, when rendering a collection `@products` the partial `_product.html.erb` can access the variable `product_counter` which indexes the number of times it has been rendered within the enclosing view. Note that it also applies for when the partial name was changed by using the `as:` option. For example, the counter variable for the code above would be `item_counter`.
|
||||||
|
|
||||||
You can also specify a second partial to be rendered between instances of the main partial by using the `:spacer_template` option:
|
You can also specify a second partial to be rendered between instances of the main partial by using the `:spacer_template` option:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue