Running a local install of Ghost latest on Mac 15.6.1 and trying to understand why I’m getting this behavior when modifying the Starter-main theme.
The examples below are from the highly simplified code I’ve been using to try to narrow down the problem, which wasn’t happening when I only had six placeholder posts in the DB but cropped up as soon as I imported the couple hundred posts already on the site I’m making a new theme for.
I want to fetch the six most recent posts and loop through them with a test partial named “foo”:
{{#get "posts" limit="6" as |post|}}
{{#foreach post }}
{{>"foo"}}
{{/foreach}}
{{/get}}
If the contents of foo.hbs are this
foo
I get what I expect
foo foo foo foo foo foo foo
but if the contents of foo.hbs are this
<article class="gh-card {{post_class}}">foo</article>
I get an infinite scroll of this
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
<article class="gh-card post">foo</article>
...
I have tried every variation of #get, #foreach, and #posts I could think of and except for the ones that failed outright they all showed the same behavior.
Removing the {{post class}} attribute, or even moving it to be the content of the element makes the behavior stop. Putting another attribute, such as {{author}} as a value of the “class” attribute does not cause the behavior, although it’s also not returning a value even when I add include=“authors” to the #get.
If anyone could explain this one to me, I’d really appreciate it because I’m about to tear out what hair I have left over it.