Metadata-Version: 2.4
Name: djule
Version: 1.0.2
Summary: Python-first server-rendered templating runtime
Author: Rhxrr
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/Rhxrrr/Djule
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Framework :: Django
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: django
Requires-Dist: Django>=4.2; extra == "django"
Provides-Extra: test
Requires-Dist: Django>=4.2; extra == "test"
Provides-Extra: dev
Requires-Dist: Django>=4.2; extra == "dev"
Dynamic: license-file

# Djule

Djule is a Python-first templating/runtime for server-rendered UI.

It currently includes:

- a lexer and parser for `.djule` files
- 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](/Users/Rhxrr/Desktop/Repos/Djule/LICENSE).

## Installation

Install the package locally:

```bash
python3 -m pip install .
```

Install from PyPI:

```bash
python3 -m pip install djule
```

Install with Django helpers:

```bash
python3 -m pip install '.[django]'
```

For local development:

```bash
python3 -m pip install -e '.[dev]'
```

## Local Development

Install the editable dev environment:

```bash
make install-dev
```

Run the Python test suite:

```bash
make test
```

Run the parser CLI:

```bash
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:

```bash
make check
make build
make clean
make clean-cache
```

## Django Integration

Djule ships a small Django-facing API in [src/djule/integrations/django.py](/Users/Rhxrr/Desktop/Repos/Djule/src/djule/integrations/django.py).

Example:

```python
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:

```python
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.
