title: flask conditional inserting of script based on url
body: <p>I want to conditionally add a script using flask's built if else template tags</p>
  
  <p>If i'm on my funding page I would like to insert my funding script</p>
  
  <p>for example:</p>
  
  <pre><code>{% if url == '/funding' %}
      &lt;script src="{{ url_for ('static', filename='js/funding.js')}}"&gt;&lt;/script&gt;
  {% endif %}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>{% if url_for == 'funding' %}
          &lt;script src="{{ url_for ('static', filename='js/funding.js')}}"&gt;&lt;/script&gt;
  {% endif %}
  </code></pre>
  
  <p>setting the context throws an error</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1994, in __call__
      return self.wsgi_app(environ, start_response)
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
      response = self.handle_exception(e)
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
      response = self.full_dispatch_request()
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
      rv = self.dispatch_request()
    File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/Users/darren/PycharmProjects/schoolDonations/schoolDonations.py", line 22, in funding
      return render_template("funding.html", url_for='funding')
    File "/usr/local/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
      context, ctx.app)
    File "/usr/local/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
      rv = template.render(context)
    File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
      return self.environment.handle_exception(exc_info, True)
    File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "/Users/darren/PycharmProjects/schoolDonations/templates/funding.html", line 1, in top-level template code
      {% extends "index.html" %}
    File "/Users/darren/PycharmProjects/schoolDonations/templates/index.html", line 5, in top-level template code
      &lt;link rel="stylesheet" href="{{ url_for ('static',
  AttributeError: 'str' object has no attribute '__call__'
  </code></pre>