I have fixed the page data injection code and it now allows adding more parameters which will be handled by FastAPI.
In the case where the render function omits the page parameter, the page data will not be passed.
The page data parameter(s) can be identifies via annotation, as page data parameter(s) are declared using the PageData
type annotation that may be imported from ez.templates.
from jsx.html import Div
from ez.templates import template, PageData
@template("page1")
def page1(my_page: PageData, query_param: str):
return Div(
my_page.id, my_page.title, my_page.content, my_page.slug
)
@template("page2")
def page2(query_param: str):
return Div(
"This template does not support page data. Data is fetched separately."
)
If the template slug contains a path parameter - such as /product/{product_id} - it can be accessed by having
a parameter with the same name (in the example, a parameter named product_id).
I have fixed the page data injection code and it now allows adding more parameters which will be handled by FastAPI.
In the case where the
render
function omits the page parameter, the page data will not be passed.The page data parameter(s) can be identifies via annotation, as page data parameter(s) are declared using the
PageData
type annotation that may be imported fromez.templates
.If the template slug contains a path parameter - such as
/product/{product_id}
- it can be accessed by having a parameter with the same name (in the example, a parameter namedproduct_id
).