Jekyll 在标记标记内部输出标记
我的问题是如何重写这个输出标记(它确实有效) 这样就可以在标记标记内部使用它(这不起作用)Jekyll 在标记标记内部输出标记,jekyll,liquid,Jekyll,Liquid,我的问题是如何重写这个输出标记(它确实有效) 这样就可以在标记标记内部使用它(这不起作用) 编辑答案: 对于本例,我使用一个自定义数组,但该数组可以是site.pages或site.posts或site.data.somedatas {% assign words = "zero,one,two,three,four,five" | split: ',' %} 然后处理单词数组: <ol> {% for word in words %} {% comment %} Here
编辑答案: 对于本例,我使用一个自定义数组,但该数组可以是site.pages或site.posts或site.data.somedatas
{% assign words = "zero,one,two,three,four,five" | split: ',' %}
然后处理单词数组:
<ol>
{% for word in words %}
{% comment %} Here we assign the filtered array to myTest {% endcomment %}
{% assign myTest = forloop.index0 | modulo:4 %}
{% comment %} then we process the filtered array {% endcomment %}
{% if myTest == 0 %}
<li>
<h4>Test passing (index = {{ forloop.index0 }} >> modulo = {{ myTest }})</h4>
</li>
{% else %}
<li>
<h4>test NOT passing (index = {{ forloop.index0 }} >> modulo = {{ myTest }})</h4>
</li>
{% endif %}
{% endfor %}
</ol>
{单词中的单词百分比为%}
{%comment%}这里我们将过滤后的数组分配给myTest{%endcomment%}
{%assign myTest=forloop.index0 |模:4%}
{%comment%}然后我们处理过滤后的数组{%endcomment%}
{%if myTest==0%}
测试通过(索引={forloop.index0}}模={{{myTest}})
{%else%}
测试未通过(索引={{forloop.index0}}模={{{myTest}})
{%endif%}
{%endfor%}
这在当前的Github页面版本Jekyll 2.2.0上有效。这就是最终有效的方法(David帮助我开始)
{%assign mod=forloop.index0 |模:4%}
{%if mod==0%}
{%endif%}
这实际上不起作用。。。我试着编辑它,但我做不到。
{% assign words = "zero,one,two,three,four,five" | split: ',' %}
<ol>
{% for word in words %}
{% comment %} Here we assign the filtered array to myTest {% endcomment %}
{% assign myTest = forloop.index0 | modulo:4 %}
{% comment %} then we process the filtered array {% endcomment %}
{% if myTest == 0 %}
<li>
<h4>Test passing (index = {{ forloop.index0 }} >> modulo = {{ myTest }})</h4>
</li>
{% else %}
<li>
<h4>test NOT passing (index = {{ forloop.index0 }} >> modulo = {{ myTest }})</h4>
</li>
{% endif %}
{% endfor %}
</ol>
{% assign mod = forloop.index0 | modulo:4 %}
{% if mod == 0 %}
<!-- Do stuff -->
{% endif %}