Closed sanzoghenzo closed 9 months ago
You are using it as I would like it to work. I have to check how Jinja treats variables inside of for loops to figure this one out. Thanks for reporting it!
Quick update:
I just implemented a test case on a new branch, and it is working as expected.
To be sure, @sanzoghenzo, are you initializing the templates
variable with:
from jinja2_fragments.fastapi import Jinja2Blocks
templates = Jinja2Blocks(directory="path/to/templates")
?
To be sure, @sanzoghenzo, are you initializing the
templates
variable with:from jinja2_fragments.fastapi import Jinja2Blocks templates = Jinja2Blocks(directory="path/to/templates")
?
Yes, sorry for not mentioning that.
This is embarassing, I should have searched jinja2 documentation first!
I needed to add scoped
after the block name to get the correct scoping of the project
variable.
Thanks a lot to taking a look at this, and sorry for the wasted time!
Hi there, thanks a lot for this great library!
I'm trying to use it with htmx to manage a table, it all works well if I replace the entire table, but if I try to use a block for the single row, then jinja complains about the missing element in the context when rendering the entire page.
The following is the htmx setup for the new project form;
The fastapi endpoints
I got an error on the get /projects endpoint:
Am I using it wrong, or is this a bug?
Obviously, after writing all of this, I realized I can swap the loop and block and pass a single element list, but it feels like a workaround rather than the solution to this problem