# Passing variables into a foreach loop in a template

**URL:** https://discourse.roots.io/t/passing-variables-into-a-foreach-loop-in-a-template/10413
**Category:** sage
**Tags:** sage9
**Created:** 2017-09-13T10:20:56Z
**Posts:** 9
**Showing post:** 2 of 9

## Post 2 by @nathobson — 2017-09-13T11:49:17Z

I wrote a little bit here: [ACF variables in blade template](https://discourse.roots.io/t/acf-variables-in-blade-template/10180/14?u=nathobson). Basically performing the full logic/loop in the controller then building a new array or object to loop through in the template which contains only the data you’re going to use.

---

_[View the full topic](https://discourse.roots.io/t/passing-variables-into-a-foreach-loop-in-a-template/10413)._
