On Friday, 1 December 2017 22.31.42 CET texas living wrote:
> I do have one more question. Say I am not sure if the last list[6] variable
> is defined, how would I write that? I tried the below but did not work.
>
> {% set title = csvfile.split("\n")[0].split(',') %}
> {% for item in csvfile.split("\n")[1:] %}
> {% set list = item.split(",") %}
> {{ list[1]|trim() }}:
> {{ title[0] }}: {{ list[0]|trim() }}
> {{ title[1] }}: {{ list[1]|trim() }}
> {{ title[2] }}: {{ list[2]|trim() }}
> {{ title[3] }}: {{ list[3]|trim() }}
> {{ title[4] }}: {{ list[4]|trim() }}
> {{ title[5] }}: {{ list[5]|trim() }}
> {% if {{ list[6] }} %}
> {{ title[6] }}: {{ list[6]|trim() }}
> {% endif %}
> {% endfor %}
You can't use {{ }} inside then template code, since you are in template mode
it understand that list[6] is a variable.
Try this
{% if list[6] is defined %}
{{ title[6] }}: {{ list[6]|trim() }}
{% endif %}
--
Kai Stian Olstad
--
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/2733638.mBYpVJAA6s%40x1.
For more options, visit https://groups.google.com/d/optout.