Reading YAML variable in a partial file and include in the template

I’ve been trying to add some “dynamic content” in a template reading the YAML of a partial file.

The following code doesn’t work

<% current_page.data.tests.each do |ingredient| %>
      <li><%= ingredient %></li>
    <% end %>

This is because current_page refers to the one being read and it doesn’t know anything about the partial. So I was wondering what could be the best option, if any.

Thanls

I struggled with this for sometime before I learned you can “pass” variables when you “call” a partial.

<%= partial "my_partials/something", locals: {current_article: current_article} %>

See the bottom of the partial page.

Thanks for this. I have now solved :smile: