Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammar correction.

Suggested change
`Litestar`_ allows you to easily render templates using a built-in templating engines,
`Litestar`_ allows you to easily render templates using 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combination of Jinja templates and register it causes some confusion. Am I registering a single template or the engine?

Suggested change
To use Jinja templates with Litestar, you can register it through the
To use Jinja with Litestar, you can register the `JinjaTemplateEngine` through the

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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