Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Storyblok PHP Richtext Renderer

This package allows you to get an HTML string from the richtext field of Storyblok.

Install dependecies

composer require storyblok/richtext-resolver dev-master

Usage:

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 />'

How to define a custom schema for resolver?

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);

Testing

We use phpunit for tests. You can execute the following task to run the tests:

composer run test

Contribution

Fork me on Github

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages