2

{% for ... %}在包含的 nunjucks 模板(例如{% include ... %})中使用循环时,循环的生成内容将呈现在<pre><code>...</code></pre>块内。

这是包含的内容:

src/includes/recipe-in​​gredients.html

<aside id="ingredients" aria-label="ingredients">
  <h3>Ingredients</h3>
  <ul>
    {% for ingredientData in recipe.ingredients %}

    <li><span class="measure">{{ ingredientData.displayQty }}</span>
    <span class="ingredient">{{ ingredientData.ingredient }}</span></li>

    {% endfor %}
  </ul>
</aside>

...这就是生成的内容:

<!-- Rest of generated HTML -->
<aside id="ingredients" aria-label="ingredients">
  <h3>Ingredients</h3>
  <ul>
<pre><code>&lt;li&gt;&lt;span class=&quot;measure&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;ingredient&quot;&gt;cinnamon&lt;/span&gt;&lt;/li&gt;


&lt;li&gt;&lt;span class=&quot;measure&quot;&gt;3/4&lt;/span&gt;
&lt;span class=&quot;ingredient&quot;&gt;sugar&lt;/span&gt;&lt;/li&gt;
</code></pre>
  </ul>
</aside>
<!-- Rest of generated HTML -->

为什么会发生这种情况,我该如何预防?

4

0 回答 0