Add more bracket angles to Django templates </>
Project description
dj-angles </>
- 📖 Complete documentation: https://dj-angles.adamghill.com/
- 📦 Package: https://pypi.org/project/dj-angles/
⭐ Features
- Use HTML-like elements in Django templates, e.g.
<dj-some-partial />instead of{% include 'some-partial.html' %} - Can be sprinkled in as needed to enhance existing Django functionality
- Since it looks like HTML, syntax highlighting mostly "just works"
- Wraps components in a custom HTML element for easier debugging and targeted CSS styling
- Support for the Shadow DOM to encapsulate component styles
- Lightweight way to submit forms via AJAX and swap in the resulting HTML
- Error boundaries to catch and display template errors
Component library integrations
- Support for Django 6.0 template partials
- django-components
- django-viewcomponent
- django-bird
- django-template-partials
Template tags
call: call functions in a templatemodel: call a model in a templateview: render a view in a template
Filters
dateformat: use Pythonstrftimeformat for formatting dates as a string
💥 Examples
<!-- base.html -->
<dj-block name='content'> <!-- {% block content %} -->
</dj-block> <!-- {% endblock content %} -->
<!-- template-tags.html -->
<dj-extends parent='base.html' /> <!-- {% extends 'base.html' %} -->
<dj-block name='content'> <!-- {% block content %} -->
<!-- components -->
<dj-some-partial /> <!-- {% include 'test-partial.html' %} -->
<dj-include template='test-partial.html' /> <!-- {% include 'test-partial.html' %} -->
<dj-verbatim> <!-- {% verbatim %} -->
This is verbatim: {% include %}
</dj-verbatim> <!-- {% endverbatim %} -->
<dj-comment> <!-- {% comment %} -->
this is a comment
</dj-comment> <!-- {% endcomment %} -->
<dj-autoescape-on> <!-- {% autoescape-on %} -->
This is escaped
</dj-autoescape-on> <!-- {% endautoescape %} -->
<dj-autoescape-off> <!-- {% autoescape off %} -->
This is not escaped
</dj-autoescape-off> <!-- {% endautoescape %} -->
<dj-csrf /> <!-- {% csrf_token %} -->
<dj-debug /> <!-- {% debug %} -->
</dj-block> <!-- {% endblock content %} -->
<!-- static-helpers.html -->
<dj-image src='img/django.jpg' /> <!-- <img src="{% static 'img/django.jpg' %}" /> -->
<dj-css href='css/styles.css' /> <!-- <link href="{% static 'css/styles.css' %}" rel="stylesheet" /> -->
<!-- call-code-from-template.html -->
<dj-call code='slugify("Hello Goodbye")' as='variable_name' /> <!-- {% call slugify("Hello Goodbye") as variable_name %} -->
<dj-model code='Book.objects.filter(id=1)' as='book' /> <!-- {% model Book.objects.filter(id=1) as book %} -->
<dj-view name='some-view' /> <!-- {% view 'some-view' %} -->
<!-- inline-expressions.html -->
{{ request.user.username or request.user.email }} <!-- {% if request.user.username %}{{ request.user.username }}{% else %}{{ request.user.email }}{% endif %} -->
{{ request.user.username if request.user.is_authenticated else 'Unknown' }} <!-- {% if request.user.is_authenticated %}{{ request.user.username }}{% else %}Unknown{% endif %} -->
<!-- error-boundaries.html -->
<dj-block name='content' error-boundary>
<dj-include template='missing-template.html' />
</dj-block>
<dj-error-boundary>
<dj-include template='missing-template.html' />
</dj-error-boundary>
<!-- ajax-form-submission.html -->
<dj-form action='/submit' method='POST' swap='outerHTML' ajax csrf> <!-- <ajax-form><form action='/submit' method='POST'>{% csrf_token %} -->
<button type='submit'>Submit</button>
</dj-form><!-- </form></ajax-form> -->
<!-- conditional-attributes.html -->
<div dj-if="True"> <!-- {% if True %}<div> -->
If
</div>
<div dj-elif="False"> <!-- {% elif False %}<div> -->
Elif
</div>
<div dj-else> <!-- {% else %}<div> -->
Else
</div> <!-- </div>{% endif %} -->
📖 Documentation
To learn how to install and use dj-angles see the complete documentation at https://dj-angles.adamghill.com/.
🧩 Django Component Libraries
There are a growing number of component libraries for Django. A non-complete list:
- Slippers: Build reusable components in Django without writing a single line of Python.
- django-components: Create simple reusable template components in Django.
- django-template-partials: Reusable named inline partials for the Django Template Language.
- django-bird: High-flying components for perfectionists with deadlines.
- django-cotton: Enabling Modern UI Composition in Django.
- django-viewcomponent: Build reusable components in Django, inspired by Rails ViewComponent.
- django-unicorn: The magical reactive component framework for Django ✨.
✨ Inspiration
🙌 Contributors
Emmanuelle Delescolle 💻 ⚠️ 📖 |
Jarkko Saltiola 📖 |
Project details
Release history Release notifications | RSS feed
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 dj_angles-0.26.0.tar.gz.
File metadata
- Download URL: dj_angles-0.26.0.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c93a0e3ebda41a5fae6b872c2e079fcbcf70d91aed8f188d323142499a5d872
|
|
| MD5 |
d27bcd504b31e546e392f1b90b0a74aa
|
|
| BLAKE2b-256 |
cb5570206d7a0b4f25044c6e5b545a441517dcd2faef5bb10797db4cafabb5bd
|
Provenance
The following attestation bundles were made for dj_angles-0.26.0.tar.gz:
Publisher:
publish.yml on adamghill/dj-angles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dj_angles-0.26.0.tar.gz -
Subject digest:
0c93a0e3ebda41a5fae6b872c2e079fcbcf70d91aed8f188d323142499a5d872 - Sigstore transparency entry: 928319209
- Sigstore integration time:
-
Permalink:
adamghill/dj-angles@26b02787f071820a6e9db6a0236a92b3d3cb7f62 -
Branch / Tag:
refs/tags/0.26.0 - Owner: https://github.com/adamghill
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26b02787f071820a6e9db6a0236a92b3d3cb7f62 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dj_angles-0.26.0-py3-none-any.whl.
File metadata
- Download URL: dj_angles-0.26.0-py3-none-any.whl
- Upload date:
- Size: 49.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee8a3000fcda40bba14198cb91e6a1bb2fbfb3f64332fac6a9c21f85018e8ed0
|
|
| MD5 |
685ef6ca47afe43170507edacb2e92c7
|
|
| BLAKE2b-256 |
89d2da78d1511faed61a5ddba8ba5a9269cff34ba1b14e5f579f5a76474bea09
|
Provenance
The following attestation bundles were made for dj_angles-0.26.0-py3-none-any.whl:
Publisher:
publish.yml on adamghill/dj-angles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dj_angles-0.26.0-py3-none-any.whl -
Subject digest:
ee8a3000fcda40bba14198cb91e6a1bb2fbfb3f64332fac6a9c21f85018e8ed0 - Sigstore transparency entry: 928319213
- Sigstore integration time:
-
Permalink:
adamghill/dj-angles@26b02787f071820a6e9db6a0236a92b3d3cb7f62 -
Branch / Tag:
refs/tags/0.26.0 - Owner: https://github.com/adamghill
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26b02787f071820a6e9db6a0236a92b3d3cb7f62 -
Trigger Event:
release
-
Statement type: