Using variable in a shortcode? #2842
-
|
I have a collection "news" where every item has an associated photo file at the same path. I succeeded in looping over the collection and displaying the correct photo file path text for every item. However, when I try to pass this PathStem variable to my image shortcode, I get an error saying Here's my .md file: How do I get around this? I feel like I'm missing something obvious. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
I'll assume you're using LiquidJS as the default .md layout engine, but this should do the trick. OUTPUT"/news/five.jpg"
<img src="/news/five.jpg" alt="Argument" />
"/news/four.jpg"
<img src="/news/four.jpg" alt="Argument" />
"/news/one.jpg"
<img src="/news/one.jpg" alt="Argument" />
"/news/three.jpg"
<img src="/news/three.jpg" alt="Argument" />
"/news/two.jpg"
<img src="/news/two.jpg" alt="Argument" /> |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, that helps! |
Beta Was this translation helpful? Give feedback.
I'll assume you're using LiquidJS as the default .md layout engine, but this should do the trick.
Not sure how nicely LiquidJS plays w/ string+variable concatenation, so I usually opt to just pre-set the value in a variable and then pass that along (see
assigntag below):OUTPUT