'Renders a template from a field. If the field is a string, it will
simply render the string and return the result. If it is a collection or
nested set of collections, it will traverse the structure and render
all strings in it.'

def render_template_from_field(self, attr, content, context, jinja_env):

    rt = self.render_template
    if isinstance(content, six.string_types):
        result = jinja_env.from_string(content).render(**context)
    elif isinstance(content, (list, tuple)):
        result = [rt(attr, e, context) for e in content]
    elif isinstance(content, dict):
        result = {k: rt(u'{}[{}]'.format(attr, k), v, context) for (k, v) in list(content.items())}
    else:
        param_type = type(content)
        msg = u"Type    '{param_type}'    used    for    parameter    '{attr}'    is    not    supported    for    templating".format(**locals())
        raise AirflowException(msg)
    return result
