Repeat node value in YAML

后端 未结 2 912
北恋
北恋 2021-01-18 06:34
pagination:
    limit:
        default: 10
        min: 0
        max: 50
        current: default

The current node should have the sa

相关标签:
2条回答
  • 2021-01-18 07:10

    You can also refer to any previous property value with ${property.name}:

    pagination:
        limit:
            default: 10
            min: 0
            max: 50
            current: ${pagination.limit.default}
    
    0 讨论(0)
  • 2021-01-18 07:11

    You can use an anchor for that, which is a token starting with & inserted before the scalar/mapping/sequence you want to "re-use". You "paste" it with an alias which is the same token preceded by a *.

    pagination:
        limit:
            default: &def 10
            min: 0
            max: 50
            current: *def
    

    (you can use default instead of def but you don't have to use the same string as the key whose value you put an anchor on)

    0 讨论(0)
提交回复
热议问题