如果我在Liquid中有一个for循环(使用Jekyll),我怎么能只针对偶数(或奇数)项?我试过了:
{% for item in site.posts %}
{% if forloop.index % 2 == 1 %}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.我也尝试过:
(forloop.index % 2) == 1
Run Code Online (Sandbox Code Playgroud)
和:
forloop.index - (forloop.index / 2 * 2) == 1
Run Code Online (Sandbox Code Playgroud) 我使用标准的jekyll安装来维护博客,一切都很顺利.除了我真的想标记我的帖子.
我可以使用YAML前端标记帖子,但是如何为每个标签生成可以列出标签所有帖子的页面?
我正在Jekyll写一个使用Liquid的网站.
我有前面的问题,我想看起来像这样:
---
title: Designing algorithms that scale horizontally
speaker: Luke Ehresman, CopperEgg
category: notes.mongodallas.talks
links:
- demo: http://www.github.com/copperegg/mongo-scaling-demo
layout: talknotes
---
Run Code Online (Sandbox Code Playgroud)
在Liquid中,YAML的链接部分来自:
[{'demo' => 'http://www.github.com/copperegg/mongo-scaling-demo' }]
Run Code Online (Sandbox Code Playgroud)
我希望能够迭代数组,做这样的事情:
<a href="{{ link.value }}">{{ link.key }}</a>
Run Code Online (Sandbox Code Playgroud)
但到目前为止,我所有的想法都让我失望了.
在这个问题上摸不着头脑 - 非常感谢.
我想显示按类别组织的所有Jekyll帖子的列表.我知道第3行不正确,但我无法弄清楚应该是什么.有任何想法吗?谢谢!
{% for category in site.categories %}
<h3>{{ category | first }}</h3>
{% for post in page.categories.category %}
{{ post.title }}<br>
{% endfor %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud) 我正在改写我的博客以使用Jekyll.Jekyll使用Liquid模板语言,因此学习如何自定义更加困难.
我想按年份将我的博客帖子分组.如何编写Liquid代码才能执行此操作?
{% for post in site.posts %}
<li><!-- display post year here (but only once, per year) --></li>
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endfor %}
Run Code Online (Sandbox Code Playgroud) 我想if在Liquid中使用带有多个条件的语句.就像是:
{% if (include.featured == "true" and product.featured == "true") or (include.featured == "false" and product.featured == "false") %}
Run Code Online (Sandbox Code Playgroud)
多个条件似乎不起作用.我的语法错误了还是Liquid不能处理这种if语句?
我正在使用markdown文件的YAML标题将excerpt变量添加到我可以在其他地方使用的博客帖子中.在其中一个摘录中,我通过降价链接标记引用了早期的博客文章,我使用液体模板数据变量{{ site.url }}代替网站的基本URL.
所以我有类似的东西(有点修剪)
---
title: "Decluttering ordination plots in vegan part 2: orditorp()"
status: publish
layout: post
published: true
tags:
- tag1
- tag2
excerpt: In the [earlier post in this series]({{ site.url }}/2013/01/12/
decluttering-ordination-plots-in-vegan-part-1-ordilabel/ "Decluttering ordination
plots in vegan part 1: ordilabel()") I looked at the `ordilabel()` function
----
Run Code Online (Sandbox Code Playgroud)
但是,jekyll和Maruku md解析器不喜欢这个,这让我怀疑你不能在YAML头中使用液体标记.
是否可以在jekyll处理的页面的YAML标题中使用液体标记?
我从Maruku得到的错误是:
| Maruku tells you:
+---------------------------------------------------------------------------
| Must quote title
| ---------------------------------------------------------------------------
| the [earlier post in this …Run Code Online (Sandbox Code Playgroud) 在Liquid模板中调用items和array时,如何调用does not contain或not in array?
我知道从我的液体模板创建数组的唯一方法是:
{% assign my_array = "one|two|three" | split: "|" %}
Run Code Online (Sandbox Code Playgroud)
还有其他办法吗?
我想知道是否有人设法在WebStorm IDE中启用Liquid模板引擎语法突出显示,我在Shopify商店上工作很多,并且非常喜欢使用Webstorm来达到这个目的.有没有人设法让这个工作?
我在JetBrain的论坛上找到了一些有关这个问题的资源,虽然它并没有让我任何地方,有一个人建议使用' tmBundle ',如果你做了一些黑魔法可能会有用.
线程是:RUBY-7210 和官方插件请求:JetBrain的插件:Liquid Templating语言请求