Skip to content

jinja2-fragments #52

Answered by volfpeter
anryangelov asked this question in Q&A
Dec 28, 2024 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Notice that the usage example from your comment does not require any change to the fasthx API. So I'll refer back to my original response:

... fasthx uses fastapi.templating.Jinja2Templates (= starlette.templating.Jinja2Templates) to render templates. If you can get jinja2-fragments working with Jinja2Templates, then it should work with fasthx as well ...

If you also have a look at the FastAPI integration of jinja2-segments, you will immediately see that it's done by sub-classing Jinja2Templates, which means you can use jinja2-segments with fasthx out of the box, you just need to pass a Jinja2Blocks instance to fasthx.Jinja, instead of fastapi.templating.Jinja2Templates.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@volfpeter
Comment options

Answer selected by anryangelov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #51 on December 28, 2024 16:18.