title: Jinja2 load templates from separate location than working directory
body: <p>I have a module that handles creating and executing SQL queries by using Jinja2 to render templates. The module itself and a directory called 'templates' are located on a network drive that I can access from multiple machines on the network.</p>
  
  <p>Everything works when I work from inside the same directory, as expected.</p>
  
  <p>When I try to load and use this module from a separate location, I get a <code>TemplateNotFound:</code> error. The function itself looks like this, with the line containing the error highlighted:</p>
  
  <pre><code>from jinja2 import Environment, FileSystemLoader, Template, meta
  
  def get_sql_query(position):
      filename = "PositionDelta.sqltemplate"
  
      # Create Jinja2 Environment, using the 'templates' folder
      env = Environment(loader=FileSystemLoader('templates')) # Error!
      template = env.get_template(filename)
  
      # Get source of template file
      template_source = env.loader.get_source(env, filename)[0]
  
      # Parse template source and get all undeclared variables
      parsed_content = env.parse(template_source)
      template_variables = list(meta.find_undeclared_variables(parsed_content))
  
      # Get all tag values associated with position
      tag_values = get_tags_list(position)
  
      # Combine template variables and tag values into dictionary and render sql query from template
      dictionary = dict(zip(template_variables, tag_values))
      sql_query = template.render(dictionary)
  
      return sql_query
  </code></pre>
  
  <p>This function that is failing is the following line:</p>
  
  <pre><code>env = Environment(loader=FileSystemLoader('templates'))
  </code></pre>
  
  <p>I think when I call the <code>FileSystemLoader</code> function, it's searching for the template folder relative to the working folder. How can I set it to look for the template directory relative to the module location itself?</p>