Our Django site is built using Mako templates. We want to use a third party project called django-socialregistration, but its template tags use Django's templates. If we used Django templates we could just
{% load facebook_tags %}
{% facebook_button %}
{% facebook_js %}
How can I do the same thing in Mako? You can inline strait up python in Mako, but I haven't figured out how to do it that way either.
Final Fix
<%! from django.template import Template, Context %>
<% tpl = "{% load facebook_tags %}{% facebook_button %}{% facebook_js %}" %>
${Template(tpl).render(Context(dict_=dict(request=request)))}
I've hardly used Mako, but if you can include arbitrary Python code, you could always inline the template rendering function there.
<%
tpl = """{% load facebook_tags %}{% facebook_button %}{% facebook_js %}"""
from django.template import Template, Context
t = Template(tpl)
t.render(Context())
%>
来源:https://stackoverflow.com/questions/3790854/mako-templates-using-django-template-tags