Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat node value in YAML

Tags:

yaml

pagination:
    limit:
        default: 10
        min: 0
        max: 50
        current: default

The current node should have the same value as the default node? (in this case, 10). Is it possible to do that with YAML?

like image 674
stefanobaldo Avatar asked Aug 17 '15 18:08

stefanobaldo


1 Answers

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)

like image 54
Anthon Avatar answered Sep 21 '22 20:09

Anthon