Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML parser with custom tags #39

Open
jasny opened this issue May 30, 2019 · 1 comment
Open

YAML parser with custom tags #39

jasny opened this issue May 30, 2019 · 1 comment

Comments

@jasny
Copy link
Member

jasny commented May 30, 2019

Example;

{
  foo: !ref abc
  bar: !tpl hello {{ planet }}
}
@jasny
Copy link
Member Author

jasny commented May 30, 2019

Quick and dirty fix in lctest

$tagToStruct = function($value, $tag) {
    $key = substr($tag, 1);
    return ["<$key>" => $value];
};

$callbacks = [
    '!ref' => $tagToStruct,
    '!eval' => $tagToStruct,
    '!ifset' => $tagToStruct,
    '!switch' => $tagToStruct,
    '!merge' => $tagToStruct,
    '!tpl' => $tagToStruct,
    '!apply' => $tagToStruct,
    '!dateFormat' => $tagToStruct
];

$scenario = yaml_parse_file($file, 0, $ndocs, $callbacks);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant