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)))}
Django Code The template tags are a way of telling Django that here comes something else than plain HTML. The template tags allows us to to do some programming on the server before sending HTML to the client.
You can't use Django's template tags from your Javascript code if that's what you mean. All the Django variables and logic stop existing after the template has been rendered and the HttpResponse has been sent to the client.
lorem. Displays random “lorem ipsum” Latin text. This is useful for providing sample data in templates. A number (or variable) containing the number of paragraphs or words to generate (default is 1).
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())
%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With