'Returns a jinja2 Environment while taking into account the DAGs
template_searchpath, user_defined_macros and user_defined_filters'

def get_template_env(self):

    searchpath = [self.folder]
    if self.template_searchpath:
        searchpath += self.template_searchpath
    env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath), extensions=[u'jinja2.ext.do'], cache_size=0)
    if self.user_defined_macros:
        env.globals.update(self.user_defined_macros)
    if self.user_defined_filters:
        env.filters.update(self.user_defined_filters)
    return env
