Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial tags not rendering local variables #908

Open
lhjd opened this issue Mar 4, 2020 · 1 comment
Open

Partial tags not rendering local variables #908

lhjd opened this issue Mar 4, 2020 · 1 comment

Comments

@lhjd
Copy link

lhjd commented Mar 4, 2020

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

  1. Add a cms partial tag to a cms layout: {{ cms:partial "path/to/partial", local_var: "value" }}
  2. This tag will be converted to <%= render partial: "path/to/partial", locals: {"local_var" => "value"} %>
  3. Inside the partial template, <%= local_var %> will not be rendered.
  4. Workaround: use <%= local_assigns["local_var"] %> to render.

I've forked the comfy-demo to illustrate the issue.
Steps to reproduce:

  1. git clone https://github.com/lhjd/comfy-demo/
  2. cd comfy-demo
  3. bundle install
  4. yarn install
  5. rails db:create
  6. rails db:migrate
  7. rails db:seed - to create a demo site called mydemo
  8. rails 'comfy:cms_seeds:import[mydemo, mydemo]' - import from mydemo cms seeds folder to mydemo site
  9. rails server
  10. go to http://localhost:3000

Actual:
image

Expected:
image

Workaround:

  1. 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:

  1. git checkout workaround
  2. 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'

@Fodoj
Copy link

Fodoj commented Jul 9, 2022

I can confirm this is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants