I'm stumbling with an error when trying to do something as simple as including a template that extends another one... I'm not sure if that's an unsupported case or I'm doing something wrong, because it seems like a very common scenario.
The smallest code that I've managed to write to reproduce the error is this:
import tornado.template
loader = tornado.template.Loader(".")
templ = loader.load("t1.html")
{% include "t2.html" %}
{% extends "t3.html" %}
{# empty #}
when running test.py
I get a NotImplementedError
raised in tornado's template.py
Am I missing something or is this a bug?
Ah, sorry, I got too focused on the missing blocks.
What you've described doesn't work using {% include %}
, but works for me using {% module Template('t2.html', **args) %}
, which will render the template in it's own namespace. Module setup is done automatically by tornado.web.Application
, but not with the minimal template loader in your example.
This limitation seems to be there because of the way the {% extends %}
tag is implemented.
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