Jekyll 使用Liquid/Jekll中的共享标识符比较不同数据文件中的项目
我正在构建一个Jekyll站点,它有一个页面,显示JSON文件中的产品信息。我想知道是否有可能通过另一个CSV文件中列出的相应数量以及库存编号来过滤显示的产品。这两个文件对每个产品使用相同的标识符。例如,沿着以下路线的东西:Jekyll 使用Liquid/Jekll中的共享标识符比较不同数据文件中的项目,jekyll,liquid,Jekyll,Liquid,我正在构建一个Jekyll站点,它有一个页面,显示JSON文件中的产品信息。我想知道是否有可能通过另一个CSV文件中列出的相应数量以及库存编号来过滤显示的产品。这两个文件对每个产品使用相同的标识符。例如,沿着以下路线的东西: {% for product in site.data.products %} {% if product.identifier == stock.identifier and current-stock < X %} Display the produc
{% for product in site.data.products %}
{% if product.identifier == stock.identifier and current-stock < X %}
Display the product
{% endif %}
{% endfor %}
{%用于site.data.products%}
{%if product.identifier==stock.identifier和当前库存
您可以使用过滤器:
{site.data.products%中的产品为%s}
-
{%assign id=product.identifier%}
{%assign data=site.data.stock |其中:“标识符”,id | first%}
{%if数据%}
{{数据|检查}
{%else%}
没有可用的数据
{%endif%}
{%endfor%}
<ul>
{% for product in site.data.products %}
<li>
{% assign id = product.identifier %}
{% assign data = site.data.stock | where: "identifier", id | first %}
{% if data %}
{{ data | inspect }}
{% else %}
No data available
{% endif %}
</li>
{% endfor %}
</ul>