提交 bc545cfd 编写于 作者: L Luke Bennett

Explain render_if_exists opts caveat

上级 bc852e05
......@@ -446,16 +446,28 @@ The disadvantage of this:
port `render_if_exists` to CE.
- If we have typos in the partial name, it would be silently ignored.
##### Caveats
The `render_if_exists` view path argument must be relative to `app/views/` and `ee/app/views`.
Resolving an EE template path that is relative to the CE view path will not work.
```haml
- # app/views/projects/index.html.haml
= render_if_exists 'button' # Will not render `ee/app/views/projects/_button` and quietly fail
= render_if_exists 'button' # Will not render `ee/app/views/projects/_button` and will quietly fail
= render_if_exists 'projects/button' # Will render `ee/app/views/projects/_button`
```
You should not explicitly set render options like `partial` or provide a `locals` hash.
The first argument should be a path string and the second can be a hash replacing `locals`.
```ruby
render partial: 'projects/button', locals: { project: project }
# becomes
render_if_exists 'projects/button', project: project
```
#### Using `render_ce`
For `render` and `render_if_exists`, they search for the EE partial first,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册