Skip to content

Latest commit

 

History

History
105 lines (76 loc) · 3.7 KB

README.md

File metadata and controls

105 lines (76 loc) · 3.7 KB

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' %}
  • 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 a JavaScript build process

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

partial.html

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

📖 Documentation

To learn how to install and use dj-angles see the complete documentation at https://dj-angles.adamghill.com/.

✨ Inspiration

🙌 Contributors

Emmanuelle Delescolle
Emmanuelle Delescolle

💻 ⚠️ 📖