【问题标题】:Sorting in Jekyll / liquid code based on two columnsJekyll/liquid 代码中基于两列的排序
【发布时间】:2020-08-06 07:15:12
【问题描述】:

在我的代码中,我试图读取大约 100 个 yml 文件并创建一个 html 表。我面临的问题是我无法根据两列进行排序。列名称是供应商和名称。 我需要先对供应商进行排序,然后再命名。

它只对供应商列排序,忽略下一列名。所有列名都是正确的。

这是代码。

         {% assign devices = "" | split: " " %}
         {% for device in site.data.devices %}
         {% assign devices = devices | push: device[1] %}
         {% endfor %}

         {% assign sorted = devices | sort_natural: 'name' | sort_natural: 'vendor' %}
         {% assign lastVendor = "" %}
         {% assign nbDevices = 0 %}

         {%- for device in sorted %}
         {%- assign nbDevices = nbDevices | plus:'1' %}
         {%- assign lastVendor = device.vendor %}` 
Here i start creating the table which gets filled with values from the yml files. 

创建时的表仅按一列排序。供应商或名称。

按照here 的建议尝试了group_by,但表格中没有显示任何值,不知道为什么。

试过sort和sort_natural两者效果是一样的。

关于我在这里做错了什么的任何建议。

【问题讨论】:

    标签: sorting markdown jekyll liquid


    【解决方案1】:

    终于搞明白了代码不工作的原因。

    我们正在使用 docker 构建我们的 jekyll 站点。泊坞窗图像已过时。 仅使用bundle exec jekyll serve 的构建解决了这个问题! 现在需要更新 bundler 和 gems....仍在弄清楚所有更新的内容,并将在此处发布以防万一。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-15
      • 2018-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 2012-02-21
      • 1970-01-01
      相关资源
      最近更新 更多