I managed to "solve" this by adding `{% include page + ".html" %}` to 
*layout_dual.html*. While not the ideal solution, it worked in this 
situation.

On Friday, April 24, 2015 at 6:11:01 PM UTC+2, Tobias Jansson wrote:
>
> Hello!
>
> Suppose I have a file named layout_dual.html, with the following contents:
>
> {% extends "layout.html" %}
> {% block before_page %}
>  <h1>Hello!</h1>
> {% endblock %}
>
> Then, in my layout.html file:
>
> <!DOCTYPE html>
> <html>
>     <head>
>         <title>Hello!</title>
>     </head>
>
>
>     <body>
>             {% block inner_page %}
>                 {% block before_page %}
>                 {% endblock %}
>                 {% include page + ".html" %}
>             {% endblock %}
>     </body>
> </html>
>
> What I would like to do is to render the block *inner_page* from the 
> layout.html template, but using the layout_dual.html template (basically 
> having *template_dual.html* "populate" the base *template.html*). Is this 
> possible?
> I can't just include template_dual.html in template.html, as 
> template_dual.html might be some other template.
>
> Right now I've a method get_block_html which looks like this (I'm also 
> using Flask, hence `current_app`):
>
> def get_block_html(template_name, block_name, **kwargs):
>     template = current_app.jinja_env.get_template(template_name)
>     context = template.new_context(vars=kwargs)
>     return template.blocks[block_name](context)
>
> This works if I render layout.html directly, but if I try to render 
> layout_dual.html `{% extends "layout.html" %}` will not be "expanded" (I 
> suppose the *render* method does this).
>
> What I am trying to accomplish is basically making Flask work with a 
> system like PJAX <https://github.com/defunkt/jquery-pjax>, though I'm not 
> using PJAX in particular but rather doing a custom solution.
>
> So, as stated above, can I accomplish this with Jinja?
>

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.

Reply via email to