Add frontmatter config into twig print function


I am trying to make a dynamic way to add images to a list. This is what I am trying to do.

          {% for item in page.header.list %}
      <div class="card">

=== Problem to fix ===

        <img class="card-img-top img-fluid" src="{{['{{ item.image }}'].url }}" alt="Card image cap">

=== End of problem to fix ===

        <div class="card-block">
          <h4 class="card-title">{% if %}<a href="{{ }}">{% endif %}{{ item.title }}{% if %}</a>{% endif %}</h4>
          <p class="card-text">{{ item.text }}</p>
        <ul class="list-group list-group-flush">
      {% endfor %}

But this does not work unfortunatly…

Is there a way to do this?

Never mind… It was simpler then i was expecting so I was searching for a complicated answer.

I just removed ‘{{}}’ only to have

{{[item.image].url }} 

and it works!

I love Grav CMS and the Grav team for their ingenious ideas and amazing work!
Learning more and more and wish to contribute when i have something to contribute other then be active in the forum :slight_smile:

Thank you!!! :smiley:


Drop the {{ }} around item.image :slight_smile:

1 Like