title: Using JavaScript variable while accessing a Jinja template value
body: <p>I am using <code>python jinja2</code> to pass <code>json</code> into a <code>HTML</code> file. The <code>json</code> I pass is similar as below,</p>
  
  <pre><code>result = { "config":{ "firstTitle" : "Report" } }
  </code></pre>
  
  <p>In my <code>HTML</code> file I have a <code>javascript</code> function as follows which works as expected,</p>
  
  <pre><code>    function dispDetails()
      {
          //This works as expected
          //It print 'Report' in the console
          console.log('{{ config.firstTitle }}');
      }
  </code></pre>
  
  <p>But if my <code>javascript</code> function is modified as to include a <code>javascript variable</code> the code is throwing erros,</p>
  
  <pre><code>function dispDetails()
      {
          //Error thrown : jinja2.exceptions.TemplateSyntaxError: expected name or number
          titleStr = "firstTitle";
          console.log('\'{{ config.'+titleStr+' }}\'');
      }
  </code></pre>
  
  <p>I have tried various ways to get this working, not sure where I am going wrong and would need some guidance on the same.</p>