I'd possibly recommend *not* building it this way, but instead building
your datastructure out programatically using Jinja2 statements.
This way you're basically iterating in Python, and setting things in Python.

# fake example follows
{% for x in y %}
    {% datastructure[x] = 'some expression' %}
{% endfor %}

At the end of the template, just dump your datastructure with:

{{ datastructure | to_nice_json }}

Templating a JSON file seems like pain to me, and that would be a lot
easier.




2014-08-13 2:42 GMT-04:00 David Neudorfer <[email protected]>:

> Thanks Lucas!
>
> I was able to accomplish my goal with
>
> {% if not loop.last %}
>     ,
> {% endif %}
>
>
>
> On Wednesday, August 13, 2014 2:15:34 AM UTC-4, Lucas, Sascha wrote:
>>
>> Hi,
>>
>> From: David Neudorfer
>> Date: Wed, 13. Aug 2014 07:51
>>
>> >      "interval": 5,
>> >      "standalone": true
>> >    },
>> > }
>>
>> I'm not sure if I understand your issue correctly... but with jinja2 you
>> can check if you are at the end of a loop:
>>
>> {% if loop.last %}some text at the end.{% else %}some text in between,{%
>> endif %}
>>
>> So your last loop should insert "," only if not at the end...?
>>
>> HTH, Sascha.
>>
>> Stellvertretender Vorsitzender des Aufsichtsrates: Detlef Hillebrand
>> Geschäftsführung: Michael Krüger
>> Sitz der Gesellschaft: Halle/Saale
>> Registergericht: Amtsgericht Stendal | Handelsregister-Nr. HRB 208414
>> UST-ID-Nr. DE 158253683
>>
>> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
>> Informationen. Wenn Sie nicht der richtige Empfänger sind oder diese E-Mail
>> irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
>> vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
>> Weitergabe dieser Mail oder des Inhalts dieser Mail sind nicht gestattet.
>> Diese Kommunikation per E-Mail ist nicht gegen den Zugriff durch Dritte
>> geschützt. Die GISA GmbH haftet ausdrücklich nicht für den Inhalt und die
>> Vollständigkeit von E-Mails und den gegebenenfalls daraus entstehenden
>> Schaden. Sollte trotz der bestehenden Viren-Schutzprogramme durch diese
>> E-Mail ein Virus in Ihr System gelangen, so haftet die GISA GmbH - soweit
>> gesetzlich zulässig - nicht für die hieraus entstehenden Schäden.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f6fef5c4-4134-4906-bb73-287a1687a2d8%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f6fef5c4-4134-4906-bb73-287a1687a2d8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgwdVAacvb%2B_z2syaGdRjeDcZzJ5YTSHUALsz0F0ibtG2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to