Toml: TOML and inheritance

Created on 25 Apr 2020  路  1Comment  路  Source: toml-lang/toml

How to do inheritance in TOML like the YAML 'merge key' feature AKA '<< *'?

And how to do more complex inheritance that YAML does not support, as suggested here [1] ?

[1] https://stackoverflow.com/questions/14184971/more-complex-inheritance-in-yaml

question

Most helpful comment

The short answer is, TOML doesn't do that.

Each and every table from root to branches in a TOML document is defined in exactly one place. No table is based on any other. So there's no concept of inheritance within TOML. It's up to the application that consumes the document to handle any complexity that comes with combining multiple configurations.

Similar questions have come up in the past. Take a look at #697 for instance. You could adapt the approach that @axos88 suggested to simulate merge-key behavior. It's not standard to TOML, but I think it's a good way for applications to do this sort of stuff.

>All comments

The short answer is, TOML doesn't do that.

Each and every table from root to branches in a TOML document is defined in exactly one place. No table is based on any other. So there's no concept of inheritance within TOML. It's up to the application that consumes the document to handle any complexity that comes with combining multiple configurations.

Similar questions have come up in the past. Take a look at #697 for instance. You could adapt the approach that @axos88 suggested to simulate merge-key behavior. It's not standard to TOML, but I think it's a good way for applications to do this sort of stuff.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tamasfe picture tamasfe  路  3Comments

hukkin picture hukkin  路  4Comments

jdfergason picture jdfergason  路  4Comments

chillum picture chillum  路  4Comments

uvtc picture uvtc  路  3Comments