Blockstudio and Sage compatibility

Hi Ben, I’ve been following some of the posts you’ve made on X along with some of the threads within the forum and when I came across this suggestion re Blockstudio thought it might be a good way to get into gutenberg native blocks without acf composer (which I really enjoy but trying something new). I have got it working within sage 11 fine via /resources/blocks/block-name/ however when trying to set it up to use blade with the package available through Sage, it strips out the script/styles from the front end. It adds those resources fine within the backend and wondered if you had any thoughts on how to get this to work with what comes packaged already within sage vs installing an outdated composer library found here Blade | Blockstudio
This is what I have in my functions.php

add_filter('blockstudio/blocks/render', function ($value, $block) {
$blockPath = $block->path;

if (! str_ends_with($blockPath, '.blade.php')) {
   return $value;
}

if (! function_exists('app') || ! app()->bound('view')) {
  return $value; // Fall back gracefully
}

$data      = $block->blockstudio['data'];
$viewVars  = [
'a'          => $data['attributes'],
'attributes' => $data['attributes'],
'b'          => $data['block'],
'block'      => $data['block'],
'c'          => $data['context'],
'context'    => $data['context'],
];

app('view')->getFinder()->addLocation(dirname($blockPath));
return app('view')->file($blockPath, $viewVars)->render();

}, 20, 2);

Do you still believe blockstudio is a good option or have you found another library which may be better for block creation for someone who isn’t big on react? I really want to stay within the sage theme if possible, I’ve always built my bespoke sites using sage + acf.

Blockstudio looks great

I haven’t had the chance to test it out, so maybe someone else can chime in if they’ve got it working in a Sage/Acorn/Radicle workflow

It’d be great to get a guide up for it — I’ll add it to my list, but can’t make any promises on a timeline to getting it written/test it out

Thanks Ben, I’ll report back if I make a breakthrough on my end :slight_smile:

Looks like the developer at Blockstudio updated their repo to address the above; the filter now works with Sage’s blade library :slight_smile: