Hi Jonathan,
We ran into what I think is probably a pretty common scenario: in a Docx template, displaying only the “checked” options in a checklist. I figured out a syntax that works, but I wonder if there’s a better solution.
Here’s what we did for the interview:
---
question: What protected class do you fall under?
fields:
- Select the protected class(es) that match you or a family member: protected_classes
datatype: checkboxes
choices:
- Family Status
- Age
- Receipt of public or rental assistance
- Gender Identity
…
And here’s what I put in the docx template:
{%p for key, value in protected_classes.iteritems() if value %}
{{ key }}
{%p endfor %}
Is there a better way to do this? It seemed more complicated than I expected.
Quinten
_______________________________________________
Docassemble mailing list
docassemble@python.org
https://mail.python.org/mm3/mailman3/lists/docassemble. python.org/