Looking for a component-based Django template rendering library
Przemysław Górecki
Posted on April 1, 2021
One of the greatest features of React is the possibility of defining components - independent and reusable bits of HTML code. I really miss it in Django templates. I imagine this could work like so:
{% component Link %}
<a href="{{href}}">{{children}}</a>
{% endcomponent %}
{% component Card %}
<div class="card">
{%if title}
<div class="card-title">{{title}}</div>
{%endif}
<div class="card-content">
{{children}}
</div>
</div>
{% endcomponent %}
{% usecomponents %}
<body>
<Card title="Foo">
I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.
<Link href="#">Click Me</Link>
</Card>
</body>
{% endusecomponents %}
How do you like the idea? Are you aware of any libraries that solves this problem?
💖 💪 🙅 🚩
Przemysław Górecki
Posted on April 1, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.