dotnetic Posted November 15, 2023 Share Posted November 15, 2023 I am as many others love ❤️the Latte template engine, and I use RockFrontend to integrate it into ProcessWire. One cool feature of Latte is, that you can easily create a comma-separated (or any other separator) list of items, where the last item does not have a separator (comma) afterwards, without needing PHP. Take this code as an example {foreach $pages->get('/myparentpage')->children as $item} {$item->title|noescape}{sep}, {/sep} {/foreach} Which will output a list like: first title, second title, third title If you want to know more use cases take a look at the documentation at https://latte.nette.org/en/tags#toc-first-last-sep 5 Link to comment Share on other sites More sharing options...
da² Posted November 15, 2023 Share Posted November 15, 2023 I think you can do shorter. ? With Twig I would do that: {{ pages.get('/').children.each('title') | join(', ') }} But usually I use html lists so WireArray API is enough: <ul>{{ pages.get('/').children.each('<li>{title}</li>') }}</ul> 2 Link to comment Share on other sites More sharing options...
dotnetic Posted November 15, 2023 Author Share Posted November 15, 2023 3 hours ago, da² said: {{ pages.get('/').children.each('title') | join(', ') }} You could do that with latte also like so: {$pages->get('/')->children->each('title') | join(', ')} 3 Link to comment Share on other sites More sharing options...
protro Posted November 18, 2023 Share Posted November 18, 2023 Great tip! Thank you @dotnetic 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now