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

Missing context when using cms_snippet_render #823

Closed
GBH opened this issue Apr 29, 2018 · 3 comments
Closed

Missing context when using cms_snippet_render #823

GBH opened this issue Apr 29, 2018 · 3 comments
Labels

Comments

@GBH
Copy link
Member

GBH commented Apr 29, 2018

If snippet content has tags that rely on context to be rendered out, we get an exception like:

Snippet content:

{{ cms:file_link 123, as: image }}

Error:

undefined method `files' for nil:NilClass
lib/comfortable_mexican_sofa/content/tags/file_link.rb:43:in `file_record'

In:

def file_record
  @file_record ||= context.site.files.detect { |f| f.id == identifier.to_i }
end

Maybe context needs to be snippet object in this case.

@GBH GBH added the bug label Apr 29, 2018
@GBH GBH closed this as completed in 56c63e5 Apr 30, 2018
@GBH
Copy link
Member Author

GBH commented Apr 30, 2018

@kirichkov this should fix your file linking issue in snippets. Confirm that it works for you and I can release new version.

@kirichkov
Copy link

Working! Thanks!

Do you think it's possible to (easily) add tag expansion for the layout's CSS/JS fields as well? Perhaps even just to include links to files in both fields?

@GBH
Copy link
Member Author

GBH commented Apr 30, 2018

Not sure about adding parsing/rendering to layout css/js. You can give a try and submit a PR though.

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

No branches or pull requests

2 participants