Closed bobbingwide closed 2 years ago
This information may help someone attempting to debug their own server side rendered block. The following message is may be shown when you attempt to create a block that is server side rendered but haven't written the server side logic.
Error loading block: No route was found matching the URL and request method
This was the case when I first developed the geshi block. I'd only written some JS; none of the PHP.
If the server side rendering doesn't return anything then you'll get a spinner.
If you see This block has encountered an error and cannot be previewed
then you should look at the JavaScript console. You might find something like this... ReferenceError: SelectControl is not defined
.
This indicates that you need to add an import statement.
Error loading block: Invalid parameter(s): attributes
is produced when one or more of the attributes passed to the server is not recognised.
Here's what I have so far.
I can make it hide the input field when the block is not selected, but can't position the input field above the server rendered output nor prevent the server rendering while I'm typing into the field.
Primary purpose is to avoid problems with unwanted p and br tags created by Gutenberg when attempting to write a post using the Block editor which contains the [bw_geshi] shortcode.
The reason this happens is because the shortcode block is rendered using
function render_block_core_shortcode( $attributes, $content ) {
return wpautop( $content );
}
It appears I need to change the oik_geshi() code to accept a default value of "none" for the lang. The server side rendering logic doesn't always want to pass "lang=none" from the SelectControl.
The logic for this block has been copied to https://github.com/bobbingwide/oik-css which is being converted to a standalone plugin for two blocks oik-css/css
and oik-css/geshi
.
Over time the solution in oik-blocks will be deprecated.
The GeSHi block is now delivered by the oik-css plugin
Requirements
Proposed solution
oik-block/geshi
- GeSHi - Generic Syntax HighlightingThis block to be added to the list of experimental blocks in #16