-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Update integration.rst to include Litestar framework #2085
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -92,3 +92,36 @@ this add this to ``config/environment.py``: | |||||
| config['pylons.strict_c'] = True | ||||||
|
|
||||||
| .. _Pylons: https://pylonsproject.org/ | ||||||
|
|
||||||
|
|
||||||
| Litestar | ||||||
| -------- | ||||||
|
|
||||||
| `Litestar`_ allows you to easily render templates using a built-in templating engines, | ||||||
| including Jinja, and integrates it seamlessly into the framework. | ||||||
|
|
||||||
| To use Jinja templates with Litestar, you can register it through the | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The combination of
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are registering the engine. Good point. |
||||||
| `template_config` parameter when creating an instance of the `Litestar` | ||||||
| application. Here's an example of how to set it up: | ||||||
|
|
||||||
| .. code-block:: python | ||||||
|
|
||||||
| from pathlib import Path | ||||||
| from litestar import Litestar | ||||||
| from litestar.contrib.jinja import JinjaTemplateEngine | ||||||
| from litestar.template.config import TemplateConfig | ||||||
|
|
||||||
| app = Litestar( | ||||||
| route_handlers=[], | ||||||
| template_config=TemplateConfig( | ||||||
| directory=Path("templates"), | ||||||
| engine=JinjaTemplateEngine, | ||||||
| ), | ||||||
| ) | ||||||
|
|
||||||
| This setup will allow you to use Jinja templates for rendering views in | ||||||
| your Litestar app. The `directory` specifies where the template files are | ||||||
| located, and the `engine` specifies which template engine to use, in this | ||||||
| case, `JinjaTemplateEngine`. | ||||||
|
|
||||||
| .. _Litestar: https://docs.litestar.dev/latest/usage/templating.html#registering-a-template-engine | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor grammar correction.