title: how to check keys variable exist and prevent printing line that key+value empty in jinja2 template
body: <p>I have jinja2 template which get data variables from yaml in the form of 'keys : value'.</p>
  
  <p>The issue is when I run jinja2 template, it will print the line that has empty 'value'. </p>
  
  <p>How can I do so that it will not print the line that is empty. Otherwise, it will appear None.</p>
  
  <p>For example;</p>
  
  <p>-Template</p>
  
  <pre><code>set first {{ABC}}
  set second {{DEF}}
  set third {{GHI}}
  </code></pre>
  
  <p>-yaml data</p>
  
  <pre><code>ABC : data1
  DEF :
  GHI : data3
  </code></pre>
  
  <p>If I run  this, it will state that;</p>
  
  <pre><code>set first data1
  set second None
  set third data3
  </code></pre>
  
  <p>I don't want it to be this way. I want it to print;</p>
  
  <pre><code>set first data1
  set third data3
  </code></pre>
  
  <p>How to do that?by preventing line from being added if the variable is undefined. </p>
  
  <p>Thanks,</p>
  
  <p>Updated script: -</p>
  
  <pre><code>TEMPLATE_FILE = { 'trial_1': 'trial.tcl' }
      for f,s in TEMPLATE_FILE.items():
  
      template = templateEnv.get_template( s )
  
      with open('tmp.yaml', 'rb') as stream:
          try:
              yaml_input_data = yaml.load(stream)
          except yaml.YAMLError as exc:
              pass
      print(yaml_input_data)
  
      for k, v in yaml_input_data.items():
          if v is None:
              yaml_input_data.pop(k)
      print(yaml_input_data)
  
      with open(f, 'w') as outfile:    
          outfile.writelines(template.render(yaml_input_data))
      print '\nWrote',f
  </code></pre>
  
  <p>Updated jinja2 template</p>
  
  <pre><code>{% for k, v in yaml_input_data.iteritems() %}
      {# use k, v #}
  set first {{ABC}}
  set second {{DEF}}
  set third {{GHI}}
  {% endfor %}
  </code></pre>