Error: Liquid syntax error: Unknown tag -- variable scope?
Error: Liquid syntax error: Unknown tag -- variable scope?
我正在尝试根据 post 的类别确定哪个 css class 给出 div,但我一直得到 [=11] =] 在我创建的变量上。
{% for post in site.posts %}
<!-- Figuring out which css class to give the cards -->
{% assign card_class = "" %}
{% if page.category == 'code' %}
{% assign card_class = "card-code" %}
{% else %}
{% assign card_class = "card-general" %}
{% endif %}
<div class="col-1-2">
<div class="paper-card {% card_class %}">
<h3>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h3>
<p class="post-excerpt"><span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>{{ post.excerpt | strip_html }}</p>
</div>
</div>
{% endfor %}
所以 {% card_class %}
抛出一个错误。超出范围了吗?有没有办法将该值添加到 class 属性中?
标签语法({% if t in toto %}
或{% comment %}
)不适合输出。
您需要使用输出语法{{ card_class }}
。
我正在尝试根据 post 的类别确定哪个 css class 给出 div,但我一直得到 [=11] =] 在我创建的变量上。
{% for post in site.posts %}
<!-- Figuring out which css class to give the cards -->
{% assign card_class = "" %}
{% if page.category == 'code' %}
{% assign card_class = "card-code" %}
{% else %}
{% assign card_class = "card-general" %}
{% endif %}
<div class="col-1-2">
<div class="paper-card {% card_class %}">
<h3>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h3>
<p class="post-excerpt"><span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>{{ post.excerpt | strip_html }}</p>
</div>
</div>
{% endfor %}
所以 {% card_class %}
抛出一个错误。超出范围了吗?有没有办法将该值添加到 class 属性中?
标签语法({% if t in toto %}
或{% comment %}
)不适合输出。
您需要使用输出语法{{ card_class }}
。