title: Flask context processors functions
body: <p>Following the minimal example on the Flask pages I'm trying to build a context processor:</p>
  
  <p>context_procesor.py</p>
  
  <pre><code>def inflect_this():
      def inflectorize(number, word):
          return "{} {}".format(number, inflectorizor.plural(word, number))
      return dict(inflectorize=inflectorize)
  </code></pre>
  
  <p>app.py(within an app factory)</p>
  
  <pre><code>from context_processor import inflect_this
  
  app.context_processor(inflect_this)
  </code></pre>
  
  <p>Using a previous inflection function that inflects a word based on number, simple I already have it as a jinja filter but wanted to see if I could do it as a context processor.</p>
  
  <p>Given the example at the bootom of the page here: <a href="http://flask.pocoo.org/docs/templating/" rel="noreferrer">http://flask.pocoo.org/docs/templating/</a>, this should work but does not. I get:</p>
  
  <pre><code>jinja2.exceptions.UndefinedError UndefinedError: 'inflectorize' is undefined
  </code></pre>
  
  <p>I do not understand enough you to see what is going on. Can anyone tell me what is wrong?</p>
  
  <p>EDIT:</p>
  
  <pre><code>app.jinja_env.globals.update(inflectorize=inflectorize)
  </code></pre>
  
  <p>works to add functions and seems to be less overhead than wrapping a method in a method, where app.context_processor probably relays to jinja_env.globals anyway. </p>