You can use @foreach instead of adding the foreach inside of a codeblock