I built a custom block that works similar to the paragraph block. However if a ToggleControl is switched it instead updates the excerpt. Whilst this correctly renders the current excerpt in both the edit and the save function, if the excerpt is changed outside of Gutenberg, such as via Wordpress admin, this block will not dynamically update.
I am looking for a way to use render callback to update the attribute before the block content is rendered.
<?php
// block render callback
if($attributes['use_excerpt']){
$attributes['content'] = get_the_excerpt();
}
echo $content;
But content was not updated and clearly needs to parse again based on this change. I could preg_match between the tags but seems very clumsy. How is this supposed to be done?