1 [![Build Status](https://travis-ci.org/grasmash/yaml-expander.svg?branch=master)](https://travis-ci.org/grasmash/yaml-expander) [![Packagist](https://img.shields.io/packagist/v/grasmash/yaml-expander.svg)](https://packagist.org/packages/grasmash/yaml-expander)
2 [![Total Downloads](https://poser.pugx.org/grasmash/yaml-expander/downloads)](https://packagist.org/packages/grasmash/yaml-expander) [![Coverage Status](https://coveralls.io/repos/github/grasmash/yaml-expander/badge.svg?branch=master)](https://coveralls.io/github/grasmash/yaml-expander?branch=master)
4 This tool expands property references in YAML files.
8 composer require grasmash/yaml-expander
19 copyright: ${book.author} 1965
20 protaganist: ${characters.0.name}
25 occupation: Kwisatz Haderach
31 occupation: Swordmaster
32 summary: ${book.title} by ${book.author}
33 product-name: ${${type}.title}
36 Property references use dot notation to indicate array keys, and must be wrapped in `${}`.
43 // Parse a yaml string directly, expanding internal property references.
44 $yaml_string = file_get_contents("dune.yml");
45 $expanded = \Grasmash\YamlExpander\Expander::parse($yaml_string);
48 // Parse an array, expanding internal property references.
49 $array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
50 $expanded = \Grasmash\YamlExpander\Expander::expandArrayProperties($array);
53 // Parse an array, expanding references using both internal and supplementary values.
54 $array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
55 $reference_properties = ['book' => ['publication-year' => 1965]];
56 $expanded = \Grasmash\YamlExpander\Expander::expandArrayProperties($array, $reference_properties);
70 'author' => 'Frank Herbert',
71 'copyright' => 'Frank Herbert 1965',
72 'protaganist' => 'Paul Atreides',
82 'name' => 'Paul Atreides',
83 'occupation' => 'Kwisatz Haderach',
93 'name' => 'Duncan Idaho',
94 'occupation' => 'Swordmaster',
97 'summary' => 'Dune by Frank Herbert',
98 'product-name' => 'Dune',