dev-master 2020-04-27 15:19 UTC

This package is auto-updated.

Last update: 2024-04-27 23:41:45 UTC


README

Supercharges YAML, based on Symfony Yaml, currently adds include feature.

License: MIT

This is a new project, might still need debugging

If you like visit my personal homepage: walter-a-jablonowski.github.io

Usage

composer require walter-a-jablonowski/super-yaml

Basic usage

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' => ...
]); 

Include

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:

scr.jpg

Replace constant string

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' => [
  
  ]
]);

Include conditionally

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 text

Include just plain text

ANY_KEY: |

   some text

   @text(sub/sub/fil.yml)
   
   some text
   
   @text( sub/sub/fil2.yml )

Changelog

  • 2020 - Fix, readme
  • 2020 - Added readme, publication
  • 2019 - Added class, improved code
  • 2018 - Initial development

LICENSE

Copyright (C) Walter A. Jablonowski 2018-2020, MIT License

Licenses of third party software see credits

Privacy | Legal