Supercharges YAML, based on Symfony Yaml, currently adds include feature.
This is a new project, might still need debugging
If you like visit my personal homepage: walter-a-jablonowski.github.io
composer require walter-a-jablonowski/super-yaml
Simliar symfony yaml
SuperYaml::parse( $yml );
SuperYaml::parseFile( $fil );
SuperYaml::dump( $yml );
SuperYaml::parse( $yml, [ // use symfony flags while parsing
'flags' => ... // difference: additional args as array
]);
SuperYaml::dump( $yml, [ // use symfony inline, indent, flags on dumping
'inline' => ... ,
'indent' => ... ,
'flags' => ...
]);
See demo/demo.php
: one yml file includes 2 yml-files
ANY_KEY: "@file(sub/sub/fil.yml)"
"@include [UNIQUE_STRING]": "@file( sub/sub/fil.yml )" # also includes key(s)
[UNIQUE_STRING] = a user defined unique string in case you are using the same key again (yml needs unique keys)
Result:
See demo/demo.php
sample under construction
ANY_KEY: "@file([REPLACE_STRING]sub/sub/fil.yml)"
"@include [UNIQUE_STRING]": "@file( [REPLACE_STRING]sub/sub/fil.yml )" # also includes key(s)
[UNIQUE_STRING] = see above
[REPLACE_STRING] = a string that will be replaced as defined in $rpl argument
SuperYaml::parse( $yml, [ // additional args as array
'rpl' => [
]
]);
You may define a list of bool vars that are used to decide wheather a file should be included. Calculate all your values before calling SuperYaml.
See demo/demo.php
sample under construction
"@includeIf(boolVar) [UNIQUE_STRING]:" ANY_VALUE
"@includeIf( boolVar ) [UNIQUE_STRING]": "@file( sub/sub/fil.yml )"
[UNIQUE_STRING] = see above
SuperYaml::parse( $yml, [
'boolVar' => [
]
]);
Include just plain text
ANY_KEY: |
some text
@text(sub/sub/fil.yml)
some text
@text( sub/sub/fil2.yml )
- 2020 - Fix, readme
- 2020 - Added readme, publication
- 2019 - Added class, improved code
- 2018 - Initial development
Copyright (C) Walter A. Jablonowski 2018-2020, MIT License
Licenses of third party software see credits