stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.34k stars 224 forks source link

Check if array contains string #290

Closed dillan closed 4 years ago

dillan commented 4 years ago

How would you suggest checking to see if an array contains a string. For example:

struct Provider: Codable {
    let items: [String]
    let selectedItems: [String]
}

{% for item in provider.items %}
    {% if provider.selectedItems contains item %}
        {{ item }} contained.
    {% else %}
        {{ item }} not contained.
    {% endif %}
{% endfor %}
acecilia commented 4 years ago
{% if variable in variablesArray %}
{% endif %}