Question

I've stumbled upon a problem with inheritence in Mako. I'll try to illustrate the problem below using two template files...

base.tpl - has a named block title:

<title><%block name="title"></%block></title>

foo.tpl - inherits from base.tpl and sets the title:

<%inherit file="base.tpl" />
<%block name="title">${title}</%block>

The template is rendered (using Bottle) with:

...
return mako_template('foo', title="My title")

Now I expected the output to be

<title>My title</title>

but instead it becomes:

<title><function render_title.<locals>.title at 0x0346A1E0></title>

Any clues? Using a different variable name than the block works.. but I'd like to use the same if possible!

Was it helpful?

Solution

Using this instead works:

<%block name="title">${context["title"]}</%block>

Does anyone know why?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top