A set of django template tools.
Project description
A set of simple tools that will make your life easier in django templates. Based on great django-classytags library.
Installation
Install the package
$> pip install django-template-goodies
put “template_goodies” into INSTALLED_APPS.
Usage: render_with
This is sort of macro-like solution allowing you to define base template that looks always the same, and fill just a “block” inside it differently.
Assuming you have partial template person_wrapper.html:
<div class="person-wrapper"> <div class="first-name">{{ first_name }}</div> {{ block }} </div>
You can use it in following way:
{% load goodies %} {% render_with "person_wrapper.html" first_name="First" last_name="Last" %} <div class="last-name">{{ last_name }}</div> {% end %}
This invocation will substitude “{{ block }}” in person_wrapper.html with the contents within “{% render_with …. %}” and “{% end %}”. So the outcome of above will be more or less:
<div class="person-wrapper"> <div class="first-name">First</div> <div class="last-name">Last</div> </div>
Usage: dict
Updates or creates dictionary inside template. You can use all kinds of filters on variable if you need:
{% load goodies %} {% dict opts name="first"|title %} {% dict opts last_name="last" value=opts.name %} {{ opts.first }} - {{ opts.last_name}} || {{ opts.value }}
The outcome will be more or less following:
First - last || first
Requirements
django-classytags
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
Hashes for django_template_goodies-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1db5bec75dbf788eddc966501b3611c157ec97ccf1e9ff1b48ca4e6fe55f2f72 |
|
MD5 | 3cc1e6615a81d86241343168503749f0 |
|
BLAKE2b-256 | b83811dd9e9e90e1212878cfd88639282a24014d678680766016efd6566cffb2 |