diff --git a/readme.md b/readme.md index 1d38736..f1ceda2 100644 --- a/readme.md +++ b/readme.md @@ -1,55 +1,37 @@ -=== Htmx Server Block === -Contributors: The WordPress Contributors -Tags: block -Tested up to: 6.1 -Stable tag: 0.1.0 -License: GPL-2.0-or-later -License URI: https://www.gnu.org/licenses/gpl-2.0.html +### Htmx Server Block +Contributors: The WordPress Contributors
+Tags: block
+Tested up to: 6.1
+Stable tag: 0.1.0
+License: GPL-2.0-or-later
+License URI: https://www.gnu.org/licenses/gpl-2.0.html
Example block scaffolded with Create Block tool, adapted for serverside rendering, and interactivity using [HTMXpress](https://github.com/svandragt/htmxpress). -== Description == +## Description -This is the long description. No limit, and you can use Markdown (as well as in the following sections). +The `render_callback` funcions simply includes a template: -For backwards compatibility, if this section is missing, the full length of the short description will be used, and -Markdown parsed. +```php + 'render_callback' => function () { + ob_start(); + load_template( __DIR__ . '/templates/random_posts.php' ); -== Installation == + return ob_get_clean(); + }, +``` +The plugin's templates are registered with HTMXpress, this makes them available under the `/htmx/` endpoint: -This section describes how to install the plugin and get it working. +```php +# register plugin's templates, which adds them to the /htmx endpoint. +add_filter( 'htmx.template_paths', static function ( $paths ) { + $paths[] = __DIR__ . '/templates'; -e.g. + return $paths; +} ); +``` -1. Upload the plugin files to the `/wp-content/plugins/htmx-server-block` directory, or install the plugin through the WordPress plugins screen directly. -1. Activate the plugin through the 'Plugins' screen in WordPress - - -== Frequently Asked Questions == - -= A question that someone might have = - -An answer to that question. - -= What about foo bar? = - -Answer to foo bar dilemma. - -== Screenshots == - -1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from -the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets -directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png` -(or jpg, jpeg, gif). -2. This is the second screen shot - -== Changelog == - -= 0.1.0 = -* Release - -== Arbitrary section == - -You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated -plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or -"installation." Arbitrary sections will be shown below the built-in sections outlined above. +The templates/random_posts.php template contains a WP_Query to load 3 random posts and a button which refreshes only the posts: +```php + echo ''; +```