This package allows you to get an HTML string from the richtext field of Storyblok.
Add the gem to your Gemfile
gem 'storyblok-richtext-renderer'
Instantiate the Resolver
class:
require_relative '../lib/storyblok/richtext'
renderer = Storyblok::Richtext::HtmlRenderer.new
Use the function render()
to get the html string from your richtext field.
# previous code...
doc = {
'type' => 'doc',
'content' => [
{
'type' => 'horizontal_rule'
}
]
}
renderer.render(doc) # renders a html string: '<hr />'
rspec spec/richtext_spec.rb
This project is open-sourced software licensed under the MIT license