Skip to main content

Want to optionally use a template tag library? Use this!

Project description

Use templatetag libraries in Django templates to optionally support features.

This app provides three template tags {% friendly_load %}, {% if_has_tag %} and {% ifnot_has_tag %}.

Used together you can built templates that have optional support for certain template tags. You can use them if they are available and do something else if they are not.

Installation

Add friendlytagloader to INSTALLED_APPS

Usage

{% load friendly_loader %} in your template

Load some optional taglib {% friendly_load comments %}

Conditionally use its tag:

{% if_has_tag render_comment_list %}
    {% render_comment_list for obj %}
{% else %}
    Comment support is not available
{% endif_has_tag %}

{% friendly_load %} takes multiple arguments, so loading multiple optional template tag libraries at once is supported:

{% friendly_load comments webdesign website_tags %}

{% if_has_tag %} and {% ifnot_has_tag %} can also handle multiple arguments.

In the case of if_has_tag this means that all given tags should be available, so this will render nothing even though now is a built-in tag:

{% if_has_tag now nonexisting_tag %}
  {% now %}
{% endif_has_tag %}

The ifnot_has_tag condition will trigger if any of the given tags is unavailable. For example this still renders the current year since nonexisting_tag is unavailable and now is a built-in tag:

{% ifnot_has_tag now nonexisting_tag %}
  {% now %}
{% endifnot_has_tag %}

Changes

1.0 (2011-10-21)

  • Initial release

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-friendly-tag-loader-1.0.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file django-friendly-tag-loader-1.0.tar.gz.

File metadata

File hashes

Hashes for django-friendly-tag-loader-1.0.tar.gz
Algorithm Hash digest
SHA256 960be7c896d2b1e26a2b97f45af8bc1ff8376b89eccada47445f8f9b01bf15fc
MD5 bf1fa974b3aff2bb667c94485c5d80b9
BLAKE2b-256 3f987347442d4595620976b152f4a85d11101a60af9e79608b9ec4056daad626

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page