Am I doing this right?
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
Is the code snippet below following best practices?
Should I be doing this on each page view?
The problem is that the variable theme can change on a per request basis so I have to set the file_system everytime. Is this ok or will it impact performance in a big way?
Liquid::Template.file_system = Liquid::LocalFileSystem.new("/path/to/liquid/#{theme.id/")
index_template = File.read("....")
template = Liquid::Template.parse(index_template)
result = template.render(h)
render html: result.html_safe
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Liquid::Template.file_system assignment, Liquid::LocalFileSystem, Template.parse, and template.render calls shown in the snippet, with attention to their per-request use. Done would require a maintainer-confirmed recommendation about whether this pattern is appropriate and its performance implications.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100