Kirby API: Blocks as HTML

Hi everybody!
Does anyone know a solution to output blocks via API as html without building a custom parser?
I am trying to render the blocks content in a VUE App.
Thanks in advance
David

You can use content representations:

1 Like

Thank you! :slight_smile:
When i set 'blocks' => $page->blocks()->toBlocks() in my json content representation I receive a data object with empty objects. What am I doing wrong? I tried some other blocks methods with no luck.

You have to convert the blocks object to HTML:

'blocks' => $page->blocks()->toBlocks()->toHtml()
1 Like