twig-tips

Don’t rely on the parent template’s variable scope.

{# _news/index.twig #}

{% for entry in craft.entries({
    section: "news",
    limit: 10,
}).all() %}
    <div>
        {% include "_components/card" with {
            entry: entry,
        } only %}
    </div>
{% endfor %}
{# _components/card.twig #}

<div>
    {% for asset in entry.listingImage.limit(1).all() %}
        <img src="{{ asset.url }}" alt="">
    {% endfor %}
    <h3>{{ entry.title }}</h3>
    {{ entry.description }}
</div>