def METHOD_NAME(self, text, context=None, *, filename=None):
    """Find dependencies for a template string."""
    lex = lexer.Lexer(text=text, filename=filename, input_encoding='utf-8')
    lex.parse()
    deps = []
    for n in lex.template.nodes:
        keyword = getattr(n, 'keyword', None)
        if keyword in ["inherit", "namespace"] or isinstance(n, parsetree.IncludeTag):
            filename = n.attributes["file"]
            if '${' in filename:
                # Support for comment helper inclusions
                filename = re.sub(r'''\${context\[['"](.*?)['"]]}''', lambda m: context[m.group(1)], filename)
            deps.append(filename)
    # Some templates will include "foo.tmpl" and we need paths, so normalize them
    # using the template lookup
    for i, d in enumerate(deps):
        dep = self.get_template_path(d)
        if dep:
            deps[i] = dep
        else:
            LOGGER.error("Cannot find template {0} referenced in {1}",
                         d, filename)
    return deps