开发者

Jinja2 templates using Django template tags

开发者 https://www.devze.com 2023-02-06 13:43 出处:网络
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

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 troubl开发者_StackOverflow社区e 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.


Should the last line not just be:

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

精彩评论

暂无评论...
验证码 换一张
取 消