Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 16 days 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 (about 15 years ago)
- Default Branch: master
- Last Pushed: 2015-12-02T20:16:06.000Z (almost 9 years ago)
- Last Synced: 2024-10-01T07:27:52.875Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 195 KB
- Stars: 211
- Watchers: 7
- 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.