title: Controlling whitespace in Pebble templates
body: <p>I'm having a hard time getting the whitespace control the way that I want in a Pebble template. I'm currently generating JSON using Pebble, but this problem and my use case is not specific to JSON (or else I would use a JSON library, such as Jackson instead). </p>
  
  <p>Here's my Pebble template:</p>
  
  <pre><code>        "items": {
              {% for item in items -%}
              "{{ item.name }}": "{{ item.value }}"{% if not loop.last %},{% endif %}
  
              {% endfor %}
  
          },
  </code></pre>
  
  <p>And, here's the generated output:</p>
  
  <pre><code>    "items": {
          "item1": "Value 1",
          "item2": "Value 2"
  
      },
  </code></pre>
  
  <p>There are two problems with this:</p>
  
  <ol>
  <li>I had to have the two blank lines in the template (one before the <code>endfor</code> and one after the <code>endfor</code>. </li>
  <li>I still end up with the extra blank line in the output before the closing squiggly bracket, i.e. the <code>},</code>.</li>
  </ol>
  
  <p>I'd like for the template to look more like the following:</p>
  
  <pre><code>        "items": {
              {% for item in items -%}
              "{{ item.name }}": "{{ item.value }}"{% if not loop.last %},{% endif %}
              {% endfor %}     
          },
  </code></pre>
  
  <p>And, I'd like for the resulting output to be:</p>
  
  <pre><code>    "items": {
          "item1": "Value 1",
          "item2": "Value 2"
      },
  </code></pre>
  
  <p>I have tried many combinations of the <a href="https://github.com/PebbleTemplates/pebble/wiki/basic-usage#whitespace" rel="nofollow noreferrer">whilespace control modifier</a>, but no luck on getting the format that I want.</p>