https://github.com/alex/django-templatetag-sugar
This project exists to make defining template tags in Django kickass
https://github.com/alex/django-templatetag-sugar
Last synced: 3 months ago
JSON representation
This project exists to make defining template tags in Django kickass
- Host: GitHub
- URL: https://github.com/alex/django-templatetag-sugar
- Owner: alex
- License: bsd-3-clause
- Created: 2009-11-07T00:27:25.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2015-12-02T20:16:06.000Z (over 9 years ago)
- Last Synced: 2025-03-29T13:08:43.600Z (3 months ago)
- Language: Python
- Homepage:
- Size: 195 KB
- Stars: 212
- Watchers: 6
- Forks: 38
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
django-templatetag-sugar
===========================A library to make writing templatetags in Django sweet.
Here's an example of using:
.. code-block:: python
from django import template
from templatetag_sugar.register import tag
from templatetag_sugar.parser import Name, Variable, Constant, Optional, Modelregister = 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 valAs you can see it makes it super simple to define the syntax for a tag.