Skip to main content

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

  1. Install the package

$> pip install django-template-goodies
  1. 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

Authors

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

django_template_goodies-0.1.2.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file django_template_goodies-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django_template_goodies-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1b0057da9c9992298a73434b1a3b85d58d49afd2f0eaa32ec79dfb2927c7a74b
MD5 7e462a1fc4dcae7ca421f1fd4da963a1
BLAKE2b-256 95508c5369099a5e8ce16856475dbb08c3b5da35ab72b362fc53c7c9ce63c891

See more details on using hashes here.

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