Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 1013 Bytes

README.md

File metadata and controls

58 lines (39 loc) · 1013 Bytes

django-neat-html

Integrate neat-html as a template backend for Django.

Examples

Installation

Using pip:

pip install django-neat-html

Configuration

Add the django_neat_html.NeatHtml template backend.

# my_project/settings.py

TEMPLATES = [
    ...
    {
        'NAME': 'neat_html',
        'BACKEND': 'django_neat_html.NeatHtml',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {},
    },
]

Usage

Write some components using the neat-html package.

# my_project/my_app/neats/components.py

from neat_html import Element, h

def my_page(context) -> Element:
    return h("h1", "My page")

Reference them as a template in your Django views.

# my_project/my_app/views.py

from django.template.response import TemplateResponse

def my_view(request):
    return TemplateResponse(request, "my_project.my_app.neats.component.my_page", {})