Closed stephenwil closed 11 years ago
Not sure at a glance. I know there are some issues parsing YAML variables in layouts, so that might be it.
If you do something like:
{% for p in page.products %}
{% image {{ page.categories }}/{{ p.image }} %}
Image: {{ p.image }}
{% endfor %}
Does the loop go all the way through?
Yes. If I add <p> {{ p.image }} </p>
into the loop, it gets rendered ok.
In the template, if it add puts @markup
at the start of the render routine of the tag, on the first iteration, it outputs {{ page.categories }}/{{ p.image }}
but on the next 3 iterations, it outputs the text from the 1st item - e.g. 'cake-boxes/cake-boxes.jpg'
That is odd. Is the include in a post or a layout?
I don't have much free time this week, but I'll take a closer look next weekend. Please post anything you find and let me know if you solve the issue. It might be worth asking on the #jekyll
channel in IRC.
Note: you can surround your HTML tags and code with backticks (`) so it's printed as code instead of rendered. Edited your post for you.
Hi, Think it's because the variable @markup on L34 is masking the scope of the @markup variable that's come in on the image call.
E.g. if I change L34 to @markup2 = Liquid::Template.parse(@markup).render(context).gsub(/{{|{\%/, '{{' => '{{', '{\%' => '{%')
and then on L39 to
markup = /^(?:(?
then @markup is always in scope, and contains the correct markup from each iteration.
Fixed!
Thanks for commenting however.
Awesome! Would you submit a pull request with your changes?
Will do.
Hi, My post contains a YAML list which I am iterating though in a for loop:
I also have an include that parses through this list in a for loop :
However, the template only ever sees the first instance in the list - and this is for each iteration.
Any idea why?