Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
in the company I work for, we were quite frustrated with the state of inline partials using Jinja2. While there are some brillant people helping with great code snippets (we linked to them), there are some limitations that make working with the existing fragment libraries in Django difficult.
What was particularly annoying was being unable to use TemplateResponse() or having to setup the environment etc. for Jinja2 again. Something that the jinja2 template backend already does today.
We had the idea to copy the existing Django Jinja2 backend and make some modifications so that it supports inline partials by rendering only specific blocks of the template.
One could certainly make the point that using the context to specify the blocks that should be rendered is not the cleanest solution, it was the best solution we could come up with that needed minimal changes to existing code or existing best practices / usecases.
All the code that is necessary for our solution to work is included in the
inline_partials_jinja2.rst
article.Please let me know what could be better as this is the first time I have worked with rst as a format.
Best
Alex