liquid: Include dynamic filename is not working
When i use
{% include folder1/folder1_1/img.jpg %}
it works perfectly, But when i try to generate the filename dynamically let’s say :
{%capture filename %} {{'folder1/folder1_1/'}}{{ images[0] }}{{ '.jpg' }}{% endcapture %}
{% include {{ filename }} %}
with images[0] = 'img'
for example, i get the error that says :
Liquid Exception: Invalid syntax for include tag. File contains
invalid characters or sequences ...
I Don’t understand why including file by providing the complete path(static path) works whereas generating the filename dynamically won’t work !
Any help would be more than appreciated.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (12 by maintainers)
Pretty sure it’s the space (see here).
Please try without it. Also your capture can be simplified… Try this: