Closed tadatuta closed 9 years ago
In php you have Arrays and Objects, so for now it supports both (there is temporary conversion from anything to stdObjects tree, because of references). So it should support syntax like
[ 'block' => 'page',
'styles' => [],
'content' => [
'Hello!',
{ 'block' => 'header', 'content' => 'Title' },
'I\'m here at the end'
]
]
So it's almost totally compatible with JS version.
Is this right?
Is it possible to call json_decode()
if argument was a string?
You mean to pass stringified json instead of arrays or objects? Sure it is.
After a talk with @tadatuta we decided to support this for testing purposes and mocks.
Examples:
// using heredoc notation
$bh->apply(<<<bemjson
{
block: "page",
content: [
'some content here'
// etc...
]
}
bemjson
);
// using standard bemjson files
$bh->apply(trim(trim(file_get_contents('bundles/index/index.bemjson')),"()"));
@tadatuta Please approve it
@zxqfox yes, that'd be just great!
I think
$BH->apply()
should use JSON as an argument or (if it's somehow possible) support both JSON and JS object syntax to have interoperability with current BEMJSON bundles or server responses.