The following code works when I use collections.pages in the set statement of this nunjucks macro. collection_name is/prints collections.pages. How do I use the value of collection_name in the last line/ set statment. Seems like this should be easy, but it doesn't seem to evaluate the value of collection_name in the set statement. Thanks!!!
{% set collection_name = ["collections.", rel_content_sections_post_type] | join %}
<p>collection_name is {{ collection_name }}</p>
{% set related_item = collection_name | findInCollectionByPropertyAndValue('data.slug', item) %}
It doesn't work because when you're setting the related_item the collection_name is just a string therefore eleventy can't work with it. But I guess you can achieve what you want by using bracket notation to access the property of the eleventy's collection you want. You can do it in the same line you set the related_item. Like this:
Then your findInCollectionByPropertyAndValue filter will receive the collection object and will be able to filter it and return whatever you want.