Skip to main content

A library to make Django's template tags sweet.

Project description

A library to make writing templatetags in Django sweet.

Here’s an example of using:

from django import template

from templatetag_sugar.register import tag
from templatetag_sugar.parser import Name, Variable, Constant, Optional, Model

register = template.Library()

@tag(register, [Constant("for"), Variable(), Optional([Constant("as"), Name()])]):
def example_tag(context, val, asvar=None):
    if asvar:
        context[asvar] = val
        return ""
    else:
        return val

As you can see it makes it super simple to define the syntax for a tag.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-templatetag-sugarv2, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_templatetag_sugarv2-1.0.1-py2.py3-none-any.whl (5.3 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size django-templatetag-sugarv2-1.0.1.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page