This package allows you to get an HTML string from the richtext field of Storyblok.
composer require storyblok/richtext-resolver dev-master
Instantiate the Resolver
class:
use Storyblok\RichtextRender\Resolver;
$resolver = new Resolver();
Use the function render()
to get the html string from your richtext field.
// previous code...
// Note that in php our objects use multidimensional array notation
$data = [
"type" => "doc",
"content" => [
[
"type" => "horizontal_rule"
]
]
];
$resolver->render($data) # renders a html string: '<hr />'
Make a copy of the default schema storyblok-php-richtext-renderer/src/Schema.php and add your own schema as parameter to the Richtext class.
$resolver = new Resolver($my_custom_schema);
We use phpunit for tests. You can execute the following task to run the tests:
composer run test
Fork me on Github