-
Notifications
You must be signed in to change notification settings - Fork 4
Components
Djazztro contains many Astro components that render into the Django templating syntax.
A simple component that renders into {% {expression} %}
<Tag expression="load static"/>
=> {% load static %}
A simple component that renders into {{ {expression} }}
<Variable expression="user.email|lower"/>
=> {{ user.email|lower }}
Technically you only need <Tag>
and <Variable>
, but some other components are provided for you.
Allows you to create {% if %} {% endif %}
blocks easily
<If expression="user.is_authenticated">
<h1>You're logged in!</h1>
</If>
=>
{% if user.is_authenticated %}
<h1>You're logged in!</h1>
{% endif %}
Allows you to create an {% elif %}
block.
<If expression="user.last_name != 'Jim'">
<h1>Hi person!</h1>
<ElseIf expression="user.first_name == 'jim@jim.com'"/>
<h1>Hi Jim!</h1>
</If>
=>
{% if user.last_name != "Jim" %}
<h1>Hi Person!</h1>
{% elif user.first_name == "Jim" %}
<h1>Hi Jim!</h1>
{% endif %}
Allows you to create {% else %}
blocks
<If expression="user.is_authenticated">
<h1>Hi, User!</h1>
<Else/>
<h1>Hi, Stranger!</h1>
</If>
=>
{% if user.is_authenticated %}
<h1>Hi, User!</h1>
{% else %}
<h1>Hi, Stranger!</h1>
{% endif %}
Allows you to loop through a list
<For itemName="user" sourceList="users">
<Variable expression="user"/>
</For>
=>
{% for user in users %}
{{ user }}
{% endfor %}
Allows you to load custom template tag libraries
<Load tagLibraryName="cool_library"/>
=>
{% load "cool_library" %}
Allows for template extension and inheritance via the block system
<Block blockName="footer">
<p>Cool site (idk these examples are hard to write)</p>
</Block>
=>
{% block "footer" %}
<p>Cool site</p>
{% endblock %}
Allows you to insert a url to another page with args
<Url name="profile" args={{id: "user.id"}}/>
=>
{% url "profile" user.id %}