Mako Templates Using Django Template Templates

Our Django website is built using Mako templates. We want to use a third-party django-socialregistration project , but its template tags use Django templates. If we used Django templates, we could just

{% load facebook_tags %}
{% facebook_button %}
{% facebook_js %}

How can I do the same in Mako? You can embed in python python in Mako, but I also did not understand how to do this.

Final fix

<%! from django.template import Template, Context %>
<% tpl = "{% load facebook_tags %}{% facebook_button %}{% facebook_js %}" %>
${Template(tpl).render(Context(dict_=dict(request=request)))}
+5
source share
1 answer

I almost never used Mako, but if you can include arbitrary Python code, you can always enable the template rendering function.

<%
    tpl = """{% load facebook_tags %}{% facebook_button %}{% facebook_js %}"""
    from django.template import Template, Context
    t = Template(tpl)
    t.render(Context())
%>
+5

All Articles