Python-first templating language and runtime for server-rendered UI
Project description
Djule
Djule is a Python-first templating/runtime for server-rendered UI.
It currently includes:
- a lexer and parser for
.djulefiles - a renderer with import resolution and render-plan caching
- a VS Code extension for syntax, diagnostics, and completions
- an optional Django integration layer
Djule is licensed under Apache License 2.0.
Installation
Install the package locally:
python3 -m pip install .
Install from PyPI:
python3 -m pip install djule
Install with Django helpers:
python3 -m pip install '.[django]'
For local development:
python3 -m pip install -e '.[dev]'
Local Development
Install the editable dev environment:
make install-dev
Run the Python test suite:
make test
Run the parser CLI:
python3 -m djule.parser check-json tests/fixtures/01_simple_page.djule
python3 -m djule.parser render tests/fixtures/01_simple_page.djule --props '{"title":"Hello Djule"}'
djule render tests/fixtures/01_simple_page.djule --props '{"title":"Hello Djule"}'
Useful maintenance commands:
make check
make build
make clean
make clean-cache
Django Integration
Djule ships a small Django-facing API in src/djule/integrations/django.py.
Example:
from djule.integrations.django import render_djule_response
def dashboard_view(request):
return render_djule_response(
request,
"examples/08_django_request_props.djule",
props={
"user": request.user,
"notifications": [],
"team": {"name": "Core"},
},
)
Set DJULE_IMPORT_ROOTS in Django settings if you want explicit import roots. Otherwise Djule falls back to BASE_DIR.
Djule can also consume Django-style global context processors. It reads the standard Django template engine TEMPLATES[..].OPTIONS.context_processors list, and you can append Djule-only ones with DJULE_CONTEXT_PROCESSORS.
Example:
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.request",
"app.utils.context_processors.debug_variable",
"app.utils.context_processors.vite_host",
],
},
},
]
DJULE_CONTEXT_PROCESSORS = [
"app.utils.context_processors.extra_djule_globals",
]
Those values are merged into every render_djule(...) / render_djule_response(...) call before explicit props, so explicit props still override globals when needed.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djule-2.0.0.tar.gz.
File metadata
- Download URL: djule-2.0.0.tar.gz
- Upload date:
- Size: 75.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf90d39b872a563c342918c187b4a943a7cfe23ec8967e14a743ae5c1561a03
|
|
| MD5 |
d5a348878f893fbd51657f9494a6d1ab
|
|
| BLAKE2b-256 |
3b75df5a2619c8f822f2cc780f5492ec08e46b259129fa75686dc1cee41002e8
|
File details
Details for the file djule-2.0.0-py3-none-any.whl.
File metadata
- Download URL: djule-2.0.0-py3-none-any.whl
- Upload date:
- Size: 69.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8713b1869e6873f594ecdf8a4fa30a25b0530a3995cdc5314c2eac860fa6632
|
|
| MD5 |
0a46917eaa9a89cde92e08b8cc04fa3d
|
|
| BLAKE2b-256 |
384dcd1a7bad470695cb7cab64dcded77d37eb1ccd2767643e9258bd1bba0461
|