Reputation: 11159
I want to integrate Mustache into my Django app. What steps would I need to take to completely replace Django's templating system with Mustache?
I would like to have render_to_response work properly with Mustache templates, passing in all the right variables with the context (STATIC_URL, request, etc.).
Upvotes: 1
Views: 725
Reputation: 5043
Basically, you have to replace the render_to_response
function with your own implementation that uses the template system of your choice. Django's render_to_response
is specific to Django's templating system. This function simply wraps some common grunt-work used when using the django template engine. The basics on how they work are covered in Django's tutorial.
Use the django.template.RequestContext
to acquire all the context variables specified in the TEMPLATE_CONTEXT_PROCESSORS
setting, (where STATIC_URL, request, etc. get defined). Since RequestContext
behaves like a dictionary, you should be able to pass it through to mustache without problems. RequestContext
takes the request object in its constructor.
Finally, don't forget to return the proper HttpResponse object!
Since I'm not much of a paragraph fan:
Upvotes: 6