Created
December 15, 2011 23:43
-
-
Save dziegler/1483525 to your computer and use it in GitHub Desktop.
A quick and dirty way to use django-uni-form with jinja2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template import Context, Template | |
from coffin.template import Library | |
from jinja2 import contextfunction | |
register = Library() | |
@register.object | |
@contextfunction | |
def uni_form(context, form, helper=None): | |
""" | |
A quick and dirty way to use django-uni-form with jinja2. | |
The same technique applies to working with other third party django templatetags. | |
In your jinja2 template:: | |
{{ uni_form(form, form.helper) }} | |
""" | |
t = Template("{% load uni_form_tags %}{% uni_form form helper %}") | |
django_context = Context(context) | |
django_context.update({'form': form, 'helper': helper}) | |
return t.render(django_context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment