The main question is how can I programatically choose what block to put some content in. The following is working in a different project, but in a fresh project this does not work for some reason. I'm using the same (default) template context processors on the same machine for both projects.
I have a base template that goes something like this
...
{% block Title %}<h1>Whoo</h1>{% endblock %}
{% block Content %}<p>Hi there</p>{% endblock %}
...
And an extending template like this
{% extends "base.html" %}
...
{% block myblock.name %} <p> {{ myblock.content }} </p> {% endblock %}
<p> {{ myblock.name }} </br> {{ myblock.content }} </p>
...
And rendering as such
myblock = { 'name': 'Title', 'content': 'stuff' }
return render_to_response( 'extended.html', {'myblock': myblock}, context_instance=RequestContext(request) )
I expect to get, and get on the first project:
...
<p> stuff <p>
<p>Hi there</p>
<p> Title </br> stuff </p>
...
But on the second project I get
...
<h1>Whoo</h1>
<p>Hi there</p>
<p> Title </br> stuff </p>
...
So on the second project, the myblock dict is passed and processed by the template but it seems that the myblock.name in {% block myblock.name %} is interpreted as a literal and not a variable. Any ideas on how to force Django to evaluate a variable inside a {% block %} tag?