comfortable-mexican-sofa
comfortable-mexican-sofa copied to clipboard
Partial tags not rendering local variables
Note: For general questions and feature requests please leave a message on Gitter: https://gitter.im/comfy/comfortable-mexican-sofa
Expected behavior
Tell us what should happen
- when we want to render a partial template using the cms partial tag, the local variables should be passed along to the partial template
Actual behavior
- the partial template is rendered, but the local variables are not passed to the template
Steps to reproduce
- Add a cms partial tag to a cms layout:
{{ cms:partial "path/to/partial", local_var: "value" }}
- This tag will be converted to
<%= render partial: "path/to/partial", locals: {"local_var" => "value"} %>
- Inside the partial template,
<%= local_var %>
will not be rendered. - Workaround: use
<%= local_assigns["local_var"] %>
to render.
I've forked the comfy-demo to illustrate the issue. Steps to reproduce:
-
git clone https://github.com/lhjd/comfy-demo/
-
cd comfy-demo
-
bundle install
-
yarn install
-
rails db:create
-
rails db:migrate
-
rails db:seed
- to create a demo site calledmydemo
-
rails 'comfy:cms_seeds:import[mydemo, mydemo]'
- import frommydemo
cms seeds folder tomydemo
site -
rails server
- go to http://localhost:3000
Actual:
Expected:
Workaround:
- use
<%= local_assigns["local_var"] %>
instead of<%= local_var %>
in the partial template
I've created a branch workaround
to illustrate this.
Steps to reproduce:
-
git checkout workaround
- go to http://localhost:3000
System configuration
Rails version: rails (6.0.2)
CMS version: comfortable_mexican_sofa (2.0.18 e13ce5d)
Ruby version: ruby '2.6.5'
I can confirm this is happening.