Replies: 1 comment 2 replies
-
why are you hesitent? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sometimes all templates share same variables (for example, username to display profile menu in the top right corner or number of items in cart). Straightforward approach would be calculating values and passing them to
Template
incontext
kwarg in each route handler.Better approach would be adding functions that take
Request
as an argument and return dict that should be merged into template context. These functions should be execute by Starlite before template rendering.Something like this
Other frameworks offer similar concept:
We already have Template Callables in Starlite which can be used to resolve the problem. However, there are two downsides:
I am hesitant about context processors.
Beta Was this translation helpful? Give feedback.
All reactions