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

nested loops #1046

Closed
Krastanov opened this issue Aug 12, 2023 · 2 comments
Closed

nested loops #1046

Krastanov opened this issue Aug 12, 2023 · 2 comments

Comments

@Krastanov
Copy link

I have a Jekyll website that heavily uses nested loops over complicated page variables as a way to generate a page. I was surprised to see that does not work in Franklin. What is the idiomatic way to do the following (pseudocode):

# file utils.jl

myvariable_d = [Dict("a"=>[1,2]),Dict("a"=>[3,4])]
myvariable_v = [[1,2],[3,4]]
# file homepage.md

{{for group in myvariable_d}}
{{for i in group["a"]}}
## {{fill i}}
{{end}}
{{end}}

{{for group in myvariable_v}}
{{for i in group}}
## {{fill i}}
{{end}}
{{end}}
@tlienart
Copy link
Owner

tlienart commented Aug 12, 2023

As soon as you have complexity like this you should move the logic to a hfun and just write Julia code for it (or if you want to keep things in the same page and not move it to utils.jl, use a hidden executed code block; or lastly you can create an unnested iterator at the definition level)

The next version will allow for a bit more flexibility in these things but the purpose is just to be more consistent, not to allow gradually more complex logic in a kind of specialised DSL like in Hugo.

@Krastanov
Copy link
Author

Thanks! Closing the issue, but feel free to move it to discussion or QnA if appropriate.

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

No branches or pull requests

2 participants