grasmash / Yaml Expander
Licence: mit
Expands internal property references in a yaml file.
Stars: ✭ 137
Projects that are alternatives of or similar to Yaml Expander
Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (-50.36%)
Mutual labels: yaml, yml
exenv
Exenv makes loading environment variables from external sources easy.
Stars: ✭ 35 (-74.45%)
Mutual labels: yaml, yml
pollly
The simplest editor to translate apps & sites for YML files. Fast and Simple. Try now!
Stars: ✭ 32 (-76.64%)
Mutual labels: yaml, yml
vim-localorie
A Vim plugin for easy look-up of translations for Rails i18n YAML keys.
Stars: ✭ 27 (-80.29%)
Mutual labels: yaml, yml
Carvel Ytt
YAML templating tool that works on YAML structure instead of text
Stars: ✭ 816 (+495.62%)
Mutual labels: yaml, yml
Yq
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
Stars: ✭ 1,688 (+1132.12%)
Mutual labels: yaml, yml
Light Push
轻量级推送服务和实时在线监控平台,同时用于开发即时通信系统,基于node的socket.io,支持web、android、ios客户端,支持移动端离线推送,可进行分布式部署
Stars: ✭ 128 (-6.57%)
Mutual labels: yaml
Oq
A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
Stars: ✭ 132 (-3.65%)
Mutual labels: yaml
Jobfunnel
Scrape job websites into a single spreadsheet with no duplicates.
Stars: ✭ 1,528 (+1015.33%)
Mutual labels: yaml
Aws Eks Kubernetes Masterclass
AWS EKS Kubernetes - Masterclass | DevOps, Microservices
Stars: ✭ 129 (-5.84%)
Mutual labels: yaml
Dropseqpipe
A SingleCell RNASeq pre-processing snakemake workflow
Stars: ✭ 119 (-13.14%)
Mutual labels: yaml
This tool expands property references in YAML files.
Installation
composer require grasmash/yaml-expander
Example usage:
Example dune.yml:
type: book
book:
title: Dune
author: Frank Herbert
copyright: ${book.author} 1965
protaganist: ${characters.0.name}
media:
- hardcover
characters:
- name: Paul Atreides
occupation: Kwisatz Haderach
aliases:
- Usul
- Muad'Dib
- The Preacher
- name: Duncan Idaho
occupation: Swordmaster
summary: ${book.title} by ${book.author}
product-name: ${${type}.title}
timezone: ${env.TZ}
Property references use dot notation to indicate array keys, and must be wrapped in ${}
.
Expansion logic:
<?php
// Set an environmental variable, accessible via ${env.TZ}.
putenv("TZ=ES");
// Parse a yaml string directly, expanding internal property references.
$yaml_string = file_get_contents("dune.yml");
$expanded = \Grasmash\YamlExpander\YamlExpander::parse($yaml_string);
print_r($expanded);
// Parse an array, expanding internal property references.
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
$expanded = \Grasmash\YamlExpander\YamlExpander::expandArrayProperties($array);
print_r($expanded);
// Parse an array, expanding references using both internal and supplementary values.
$array = \Symfony\Component\Yaml\Yaml::parse(file_get_contents("dune.yml"));
$reference_properties = ['book' => ['publication-year' => 1965]];
$expanded = \Grasmash\YamlExpander\YamlExpander::expandArrayProperties($array, $reference_properties);
print_r($expanded);
Resultant array:
<?php
array (
'type' => 'book',
'book' =>
array (
'title' => 'Dune',
'author' => 'Frank Herbert',
'copyright' => 'Frank Herbert 1965',
'protaganist' => 'Paul Atreides',
'media' =>
array (
0 => 'hardcover',
),
),
'characters' =>
array (
0 =>
array (
'name' => 'Paul Atreides',
'occupation' => 'Kwisatz Haderach',
'aliases' =>
array (
0 => 'Usul',
1 => 'Muad\'Dib',
2 => 'The Preacher',
),
),
1 =>
array (
'name' => 'Duncan Idaho',
'occupation' => 'Swordmaster',
),
),
'summary' => 'Dune by Frank Herbert',
'product-name' => 'Dune',
'timezone' => 'ES',
);
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].