【问题标题】:if statement in jekyll + liquid create codeblock instead of intened html tagsjekyll + Liquid 中的 if 语句创建代码块而不是预期的 html 标签
【发布时间】:2019-03-20 16:29:03
【问题描述】:

嘿,我有 Jekyll 中的每个循环,它在每个增量中都会增加变量 phdCount 的计数,我这样做是这样的:{% assign phdCount = phdCount | plus:1 %}。当phdCount == 3 为真时,我不会关闭 boostrap 行并开始新的 so,我尝试这样做:

{% if phdCount == 3 %}
    </div>
    <div class="row">
{% endif %}

这应该让我在我的 HTML 中关闭和打开 div 标记。但我得到的是 HTML 中的代码块,其中包含如下所示的标签:

我没有在/lib 中包含任何自定义宝石或任何东西。关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: jekyll liquid


    【解决方案1】:

    由于缩进/间距,页面正在使用代码块呈现。

    {% if phdCount == 3 %}
        </div>
        <div class="row">
    {% endif %}
    

    应该是

    {% if phdCount == 3 %}
    </div>
    <div class="row">
    {% endif %}
    

    这将删除代码块。但是,页面认为可能存在代码块而不只是将其严格视为 HTML 代码这一事实意味着页面可能存在其他问题。如果您在尝试混合 HTML 的 .md 文件中,那么这可能是代码块的来源。如果您在 .html 文件中,则可能是其他问题。

    您能显示{% if %} 块周围的代码吗?

    【讨论】:

    • 我错过了&lt;/div&gt;,它是缩进。非常感谢:)
    猜你喜欢
    • 1970-01-01
    • 2013-07-24
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 2019-03-20
    • 2012-06-22
    • 2023-02-15
    • 1970-01-01
    相关资源
    最近更新 更多