Skip to main content

Add more bracket angles to Django templates </>

Project description

dj-angles </>

Add more bracket angles to Django templates

PyPI PyPI - Downloads GitHub Sponsors

⭐ Features

  • Use HTML-like elements in Django templates, e.g. <dj-partial /> instead of {% include 'partial.html' %}
  • Wraps include templates in a custom element for easier debugging and targeted CSS styling
  • Can be sprinkled in as needed to enhance existing Django functionality
  • Since it looks like HTML, syntax highlighting mostly "just works"
  • Integrates with Django component libraries like django-bird
  • Lets you excitedly tell your friends how neat the Shadow DOM is
  • Pretend like you are writing React components, but without dealing with JavaScript at all

💥 Example

base.html

<dj-block name='content'>
</dj-block name='content'>

index.html

<dj-extends parent='base.html' />  <!-- {% extends 'base.html' %} -->

<dj-block name='content'>  <!-- {% block content %} -->
  <dj-include template='partial.html' />  <!-- {% include '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-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" /> -->
</dj-block name='content'>  <!-- {% endblock content %} -->

partial.html

<div>
  This is a partial: {{ now|date:"c" }}
</div>

📖 Documentation

To learn more about how to install and use dj-angles go to https://dj-angles.adamghill.com/.

✨ Inspiration

I have been interested in Django components and encapsulating functionality for a long time (see django-unicorn, dlitejs, etc), but had never thought of using HTML directly until I looked at Cotton by wrabit. dj-angles takes the initial idea further to see how well it works.

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

dj_angles-0.8.1.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

dj_angles-0.8.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file dj_angles-0.8.1.tar.gz.

File metadata

  • Download URL: dj_angles-0.8.1.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.7

File hashes

Hashes for dj_angles-0.8.1.tar.gz
Algorithm Hash digest
SHA256 83f220f7f78afeb82aa2547a365cb3340dec88b5b5b40281f5d681cbbe811230
MD5 0749b3f8950700045a24f1224c284ef5
BLAKE2b-256 b8de2e2e01a1d7461f87ca47c601de6d9b3d14899d2d7071627260d410160527

See more details on using hashes here.

File details

Details for the file dj_angles-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: dj_angles-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.7

File hashes

Hashes for dj_angles-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c8846cc6cfcee84eee6ade7f11f4354df9c74b5a381a579f8760237fcf6eb58
MD5 96eeb635f5d71089dd90b2c9a5f972a0
BLAKE2b-256 a6325648b40a75c82c9b3abbcca32097a8fce26ad116969fe8b492d982632dc5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page