Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance foreach tag to support dynamic variables #4012

Merged
merged 2 commits into from
Aug 23, 2021
Merged

Enhance foreach tag to support dynamic variables #4012

merged 2 commits into from
Aug 23, 2021

Conversation

aerni
Copy link
Contributor

@aerni aerni commented Jul 16, 2021

This PR adds the option to pass a variable by parameter. This makes it possible use dynamic variables:

{{ foreach :array="fields[field].options" }}
    ...
{{ /foreach }}

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a little tweak here, but otherwise 👍 Thanks!

You introduced a small issue where if you did {{ foreach:unknown }}..{{ /foreach:unknown }} it'll actually try to use the string "unknown" for the loop.

@jasonvarga jasonvarga merged commit 23d1da2 into statamic:3.1 Aug 23, 2021
jasonvarga added a commit that referenced this pull request Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants