views:

27

answers:

1

I'm making a simple script that works on Jinja2 templates. Right now it's just reading files in from disk manually, i.e. no Jinja Loaders. I have 2 strings (A and B), representing 2 templates. I want to make one template (B) inherit from the other (A), i.e. I have {% block body %}{% endblock %} in A, and I want to make the body block be the contents of B. How can I get the rendered output of this?

Normally I'd use {% extends 'filename' %} in B and it'd use the right one, however I don't have the filename (per se) for A.

+3  A: 

Your best bet probably to use a different template loader. Take a look at DictLoader and FunctionLoader, or try your hand a writing your own template loader.

Daniel