title: How to store Jinja2 template output as a string
body: <p>I want to use Jinja2 to store a template as a string variable in python instead of rendering it as a file. How would I go about doing this ?</p>
  
  <p>For example using f-strings I'd do :</p>
  
  <pre><code>template = f""" This is a {foo}"""
  </code></pre>
  
  <p>Unfortunately f-strings don't suit my needs hence I wanted to try out Jinja2.</p>
  
  <p><strong>Edit :</strong>
  Requirement</p>
  
  <pre><code>cars = {
    'tesla': {
      'cost': '34000',
      'length': '185',
      'range': '220',
    },
    'chevy': {
      'cost': '37000',
      'length': '134',
      'range': '238',
    }
  </code></pre>
  
  <p>I would like to take the values from this dictionary, insert it into template and store it as a string to be used later.</p>
  
  <p>I tried using the below code but I get an invalid syntax error.</p>
  
  <pre><code>template1 = Template("""Tesla 
                          Cost : {{ cars.tesla.cost }}""")
  template2 = template1.render()
  
  # Expected Output
  print(template2)
  Tesla
  Cost : 34000
  </code></pre>