Integrate neat-html
as a template backend for Django.
Using pip:
pip install django-neat-html
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': {},
},
]
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", {})