基于两列按Jekyll/液体代码排序 [英] Sorting in Jekyll / liquid code based on two columns

查看:65
本文介绍了基于两列按Jekyll/液体代码排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my code I am trying to read about 100 yml files and create an html table. The problem I am facing is I am unable to sort based on two columns. The column names are vendor and name. I need to first sort on Vendor and then name.

它仅在一个列上对vendor列进行排序,而忽略下一个列名.所有列名都是正确的.

It sorts on one columns only the vendor column and ignore the next column name.. All the column names are correct.

这是代码.

         {% 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. 

创建后的表格仅在一列上排序.供应商或名称.

The table when created is sorted on only one column. Either vendor or name.

根据建议group_by" >此处,但随后表格中没有显示任何值,不确定原因.

Tried group_by as suggested here but then no values show up in the table not sure why.

尝试排序和sort_natural的效果是相同的.

Tried sort and sort_natural both the effect is the same.

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

Any suggestions as to what I am doing wrong here.

推荐答案

最后弄清楚了为什么代码无法正常工作.

Finally figured out why the code was not working.

我们正在使用docker构建我们的jekyll网站.泊坞窗映像已过时. 仅使用bundle exec jekyll serve的构建即可解决该问题! 现在需要更新捆绑器和gems....仍在弄清楚所有更新的内容,并将在此处发布以防对任何人有帮助.

We were building our jekyll site using docker. The docker image was outdated. A build using just bundle exec jekyll serve resolved the issue !! Now need to update the bundler and gems....still figuring out what all gets updated and will post here in case it helps anyone.

这篇关于基于两列按Jekyll/液体代码排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆