summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-05-16 16:55:34 +0000
committerPhil Hughes <me@iamphill.com>2019-05-16 16:55:34 +0000
commita37a62cf18f2325e2836ee02135a5b89cefc8a4e (patch)
treef825b2325357021e8d542550aeac8e2c0ef77e9b
parent8cd466ac3eab915328da51c42497c2c923d72f79 (diff)
parentbc545cfd7cb0c1405943aac55881356c9016b1c3 (diff)
downloadgitlab-ce-a37a62cf18f2325e2836ee02135a5b89cefc8a4e.tar.gz
Merge branch 'docs-render_if_exists-opts-caveat' into 'master'
Explain render_if_exists opts caveat See merge request gitlab-org/gitlab-ce!28366
-rw-r--r--doc/development/ee_features.md14
1 files changed, 13 insertions, 1 deletions
diff --git a/doc/development/ee_features.md b/doc/development/ee_features.md
index 8706fe537fa..9db28bcddf8 100644
--- a/doc/development/ee_features.md
+++ b/doc/development/ee_features.md
@@ -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,