title: How to get the name of the Flask blueprint inside a template?
body: <p>I have a site built with Flask. It has several sections, each with a dedicated blueprint. The templates in each blueprint extend a base template, which has the basic layout for each page, including a navigation bar with tabs for each section.</p>
  
  <p>I'd like to have the base template highlight the current tab, so it needs to know which blueprint's view is handling the request.</p>
  
  <p>One way I came up with to do this is to add a <code>before_request</code> handler to each blueprint and store the name in <code>g</code>:</p>
  
  <pre class="lang-py prettyprint-override"><code>bp = Blueprint('blog', __name__, url_prefix='/blog')
  
  @bp.before_request
  def set_bp_name():
      g.section = 'blog'
  </code></pre>
  
  <p>But Flask must know which blueprint is handling a request (if any) and the blueprint, of course, knows its own name. Is there a way for the template to fetch the current blueprint's name that doesn't require modifying each blueprint?</p>