title: get content from parent block in jinja2
body: <p>I need to get content from particular block in Jinja2 by console script. For example</p>
  
  <pre><code>//global template
  {% block target %}
      &lt;some_content_from_top&gt;
  {% endblock %}
  
  //parent template
  {% extends 'top.html' %}
  {% block target %}
      &lt;some_content_from_parent&gt;
  {% endblock %}
  
  //child template
  {% extends 'parent.html' %}
  {% block target %}
      &lt;some_content&gt;
  {% endblock %}
  </code></pre>
  
  <p>I can use something like that to get content from this block in particular template without inheritanse</p>
  
  <pre><code>template_source = self.env.loader.get_source(self.env, template_path)[0]
  parsed_content = self.env.parse(template_source).body
  # do something with blck content
  </code></pre>
  
  <p>But how I can get content from all parent templates.Of course I can get parent template name from Extends block and do the same manipulations over and over again tiil I get top-level template without Extends block. But maybe there are more efficient way?</p>