title: Get variables from Jinja2 template
body: <p>I need to extract variable names (with JSON) from this Jinja2 template with functions:</p>
  
  <pre><code>{{ variable }}
  {{ some.variable.type.json }}
  {{ _("Hello") }}
  &lt;p&gt;Some HTML file&lt;/p&gt;
  </code></pre>
  
  <p>I need to get output something like this:</p>
  
  <pre><code>{'some': {'variable': {'type': {'json': &lt;scalar&gt;}}}, 'variable': &lt;scalar&gt;}
  </code></pre>
  
  <p>Or this:</p>
  
  <pre><code>["some.variable.type.json", "variable"]
  </code></pre>
  
  <p>I tried Environment from jinja2:</p>
  
  <pre><code>from jinja2 import Environment, FileSystemLoader, meta
  
  env = Environment(loader=FileSystemLoader(""))
  template_source = env.loader.get_source(env, "test.html")[0]
  parsed_content = env.parse(template_source)
  variables = meta.find_undeclared_variables(parsed_content)
  print(variables)
  </code></pre>
  
  <p>But it returns function names in output and don't return all JSON name:</p>
  
  <pre><code>{'some', 'variable'}
  </code></pre>
  
  <p>I tried jinja2schema too:</p>
  
  <pre><code>import jinja2schema
  
  with open("test.html", mode="r") as f:
      template = str("".join(f.readlines()))
      variables = jinja2schema.infer(template)
  
      print(variables)
  </code></pre>
  
  <p>It returns what I want without functions, but when in HTML is some Jinja2 function, then I got Exception:</p>
  
  <pre><code>jinja2schema.exceptions.InvalidExpression: line 3: "_" call is not supported
  </code></pre>
  
  <p>Is there any way to get full variables from Jinja2 template withou function names?
  Thanks for help</p>