diff options
author | Zachary Scott <e@zzak.io> | 2015-02-12 10:00:32 -0800 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2015-02-12 10:00:32 -0800 |
commit | 8d0fe8047a3c630d29224688ecfa4f4b26cb238a (patch) | |
tree | 163b3f7734e4da75b404edacc9dd2f528214a6d3 /guides | |
parent | 76f6524538a50b4e3ede3d1ae58fcfbac3e77a91 (diff) | |
parent | 1faadfdbcb60a6045c8d773910c5212b64ab46a3 (diff) | |
download | rails-8d0fe8047a3c630d29224688ecfa4f4b26cb238a.tar.gz rails-8d0fe8047a3c630d29224688ecfa4f4b26cb238a.tar.bz2 rails-8d0fe8047a3c630d29224688ecfa4f4b26cb238a.zip |
Merge pull request #18844 from yuki24/guides-add-render-example-without-partial-and-locals
Add tip for skipping `partial` and `locals` options for `render`
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/action_view_overview.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index 665a2b71ff..fa6d85a3ee 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -190,6 +190,21 @@ One way to use partials is to treat them as the equivalent of subroutines; a way Here, the `_ad_banner.html.erb` and `_footer.html.erb` partials could contain content that is shared among many pages in your application. You don't need to see the details of these sections when you're concentrating on a particular page. +#### `render` without `partial` and `locals` options + +In the above example, `render` takes 2 options: `partial` and `locals`. But if these are the only options you want to pass, you can skip using these options. For example, instead of: + +```erb +<%= render partial: "product", locals: {product: @product} %> +``` + +You can also do: + +```erb +<%= render "product", product: @product %> +``` + + #### The `as` and `object` options By default `ActionView::Partials::PartialRenderer` has its object in a local variable with the same name as the template. So, given: |