Condition (if, else, else if) in YAML

Benjamin Le Gallo picture Benjamin Le Gallo · Aug 23, 2018 · Viewed 10.2k times · Source

I use hautelook/AliceBundle to create faker data in YAML, but I would for more consistency of data.

I would like that:

gender: <randomElement(['Homme', 'Femme'])>
if $gender == 'Homme'
    title: 'Monsieur'
else if $gender == 'Femme'
    title: 'Madame'

I know it's not directly possible in YAML, but I do not know which plugin to use... And how to.

My tools/languages used in my project (Symfony, hautelook/AliceBundle, PHP, YAML)

Answer

mwa91 picture mwa91 · Mar 7, 2019

You cannot do that. YAML is data serialization language, not a programming language.