title: Pass variables to Tornado base templates
body: <p>I have a base template base.html from which other templates inherit from. </p>
  
  <p>After a user logs on I want to display their userID on navigation bar defined in base.html</p>
  
  <p>So I have:</p>
  
  <pre><code>class CloseHandler(tornado.web.RequestHandler):   
      def get(self):       
          ui=db.users.find_one({"Username": ui0})        
          self.render("thanks.html" , ui1 = ui["Username"])
  </code></pre>
  
  <p>I also want to display the value of ui1 in the base template as: <code>&lt;p&gt;{{ ui1 }}&lt;/p&gt;</code></p>
  
  <p>The only way round this is to move my navigation bar html code from base.html and insert it into every other template.</p>
  
  <p>I however get this error:</p>
  
  <pre><code> NameError: global name 'ui1' is not defined
  </code></pre>
  
  <p>I've tried setting this as a global variable but it still gives the same error.</p>
  
  <p>How could variables be used in different templates then?</p>