Skip to main content

Add more bracket angles to Django templates </>

Project description

dj-angles </>

PyPI PyPI - Downloads GitHub Sponsors All Contributors

⭐ Features

  • Use HTML-like elements in Django templates, e.g. <dj-partial /> instead of {% include 'partial.html' %}
  • Can be sprinkled in as needed to enhance existing Django functionality
  • Since it looks like HTML, syntax highlighting mostly "just works"
  • Wraps included templates in a custom element for easier debugging and targeted CSS styling
  • Support for making components with the Shadow DOM
  • Integrates with Django component libraries like django-bird
  • call and model template tags to call functions directly from a template
  • dateformat filter to use Python strftime formats instead of PHP when formatting dates

💥 Example

base.html

<dj-block name='content'>  <!-- {% block content %} -->
</dj-block>  <!-- {% endblock content %} -->

index.html

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

<dj-block name='content'>  <!-- {% block content %} -->
  <!-- components -->
  <dj-partial />  <!-- {% include 'partial.html' %} -->
  <dj-include template='partial.html' />  <!-- {% include 'partial.html' %} -->

  <!-- evaluate code from the template -->
  <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 %} -->

  <!-- conditional attributes -->
  <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 %} -->

  <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 %} -->

  <!-- static helpers -->
  <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>  <!-- {% endblock content %} -->

📖 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
Emmanuelle Delescolle

💻 ⚠️ 📖

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.17.0.tar.gz (93.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_angles-0.17.0-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dj_angles-0.17.0.tar.gz
  • Upload date:
  • Size: 93.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dj_angles-0.17.0.tar.gz
Algorithm Hash digest
SHA256 79681126baa846d2d788fa6cbc71609ddbaa8c6c64a85fbf7d116ac7457e6534
MD5 c2f9a4510285177d564fbff4f669b961
BLAKE2b-256 7c920d9e15081d344dabf132a003d93b0752672172ed8c7737dd26b824cb3f73

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_angles-0.17.0.tar.gz:

Publisher: publish.yml on adamghill/dj-angles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: dj_angles-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dj_angles-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9503bbf6b7e3ecbb5ea9778f27af13153e003b17b2955698e5562f0375cfdc4
MD5 1f68dd593d1945b5c9ae91c6d40b118e
BLAKE2b-256 93059ee97f547d866eee210c940a7a4d512fce27ecd614a9720eee1de8941fb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_angles-0.17.0-py3-none-any.whl:

Publisher: publish.yml on adamghill/dj-angles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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