Jekyll YAML循环参考 [英] Jekyll YAML cyclic reference

查看:58
本文介绍了Jekyll YAML循环参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个页面的jekyll项目,每个页面均由相互引用的YAML映射支持.例如:

I have a jekyll project with two pages, each backed by YAML maps that both reference each other. For example:

a: &a
  name: "Ay"
  parents: []
  children: [*b]

b: &b 
  name: "Bee"
  parents: [*a]
  children: []

Vanilla YAML似乎不支持在定义别名/锚之前使用别名/锚,这会使该策略无效.有什么办法,也许使用液体富让我生成列举条目的父母和孩子的页面?

Vanilla YAML seems not to support using an alias/anchor before its been defined, which invalidates this strategy. Is there any way, perhaps using liquid-fu that would let me generate pages that enumerate an entry's parents and children?

推荐答案

您只需要在首次出现时提供该值:

You just need to give the value on first occurrence:

a: &a
  name: "Ay"
  parents: []
  children:
    - &b
      name: "Bee"
      parents: [*a]
      children: []
b: *b

alias/anchor构造是专门为该用例设计的.由于解析的YAML数据无法区分对象的锚定位置和引用的位置,因此这等同于您想要的对象.

The alias/anchor construct has been designed specifically for this use-case. Since the parsed YAML data does not distinguish the place where the object is anchored and the place where it is referenced, this is equivalent to what you want to have.

这篇关于Jekyll YAML循环参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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