Joe
Joe

Reputation: 26837

Jinja2 templates using Django template tags

I'm using Jinja2 on a new project, but would like to use the django-socialregistration app, which relies on Django template tags. Jinja2 doesn't play nicely with template tags, so I'm wondering if there's a quick workaround?

Template tags:
{% load facebook_tags %}
{% facebook_button %}
{% facebook_js %}

This previous question addresses the same topic for Mako, but I'm having trouble adapting it to work with Jinja2. The following is my attempt at an adaptation (non-working):

{% from django.template import Template, Context %}
{% tpl = "{% load facebook_tags %}{% facebook_button %}{% facebook_js %}" %}
${Template(tpl).render(Context(dict_=dict(request=request)))}

Any advice? I'm new to inlining, so don't know if the above is even close.

Upvotes: 4

Views: 1925

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 600059

Should the last line not just be:

{% Template(tpl).render(Context(dict=dict(request=request))) %}

Upvotes: 1

Related Questions