title: How to add a new entry into a dictionary object while using jinja2?
body: <p>I am not able to append add a new entry into a dictionary object while using jinja2 template.</p>
  
  <p>For example, here I am using jinja2 template and I have created a <strong>data</strong> variable which is a dictionary. And after checking some <em>if</em> condition I <strong><em>WANT</em></strong> to append location attribute to the data object e.g.</p>
  
  <pre><code>{%- set data = {
                    'name' : node.Name,
                    'id' : node.id,
                 }
  -%}
  
  {% if node.location !="" %}
      data.append({'location': node.location}) 
  {% endif %}
  </code></pre>
  
  <p>However I could not find a way to achieve this and am getting the UndefinedError:</p>
  
  <pre><code>jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'append'
  </code></pre>
  
  <p><em>Has anyone faced this issue or could provide a reference to solve this?</em></p>
  
  <p>I searched the web but could not find a solution i.e. how to achieve adding an entry to the dict object in the Jinja.</p>
  
  <p>I have referred following and other web resources:</p>
  
  <ol>
  <li><a href="http://cewing.github.io/training.codefellows/assignments/day22/jinja2_walkthrough.html" rel="noreferrer">http://cewing.github.io/training.codefellows/assignments/day22/jinja2_walkthrough.html</a></li>
  <li><a href="https://stackoverflow.com/questions/3352724/in-jinja2-whats-the-easiest-way-to-set-all-the-keys-to-be-the-values-of-a-dictio">In Jinja2 whats the easiest way to set all the keys to be the values of a dictionary?</a></li>
  <li><a href="https://github.com/saltstack/salt/issues/27494" rel="noreferrer">https://github.com/saltstack/salt/issues/27494</a></li>
  </ol>