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

Add inline partials with Jinja2 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kummerer94
Copy link

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

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

Successfully merging this pull request may close these issues.

None yet

1 participant