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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-templatetag-sugar-1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f630549f6c174cf328b385190e18bfe308f74dc7eca13458163d316ed29a5e |
|
MD5 | 40da36b5a4bf98fdff867f2ccd5bb34e |
|
BLAKE2b-256 | 95450f2b31e4e86a9df1151c4c3a5f8ff1fb9bd882785d7c90ef1629fce37636 |
Close
Hashes for django_templatetag_sugar-1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90beafe5bc84686c328dcf685ce9f59f814104efd9a1fb5fb826e3ee3b7c2626 |
|
MD5 | 2497218f87b4ffe61288b8dec8a33ef6 |
|
BLAKE2b-256 | 7261ec7b883ff5f8d0641eea522b23e382918d214b27c1f63c5449ac0bcba1e7 |