Skip to content

Commit

Permalink
Add attributes to ServerSideRender readme (#12793)
Browse files Browse the repository at this point in the history
* Add attributes to ServerSideRender readme

Adds a code example demonstrating how to define attributes when registering a block that will use attributes in a ServerSideRender component.

* Add whitespace and inline code markup to ServerSideRender readme

Implements requested changes from code review.
  • Loading branch information
NateWr authored and chrisvanpatten committed Dec 11, 2018
1 parent 1a1dc7c commit 0fba129
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/components/src/server-side-render/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,25 @@ Output uses the block's `render_callback` function, set when defining the block.

## API Endpoint

The API endpoint for getting the output for ServerSideRender is `/wp/v2/block-renderer/:block`. It accepts any params, which are used as `attributes` for the block's `render_callback` method.

The API endpoint for getting the output for ServerSideRender is `/wp/v2/block-renderer/:block`. It will use the block's `render_callback` method.

If you pass `attributes` to `ServerSideRender`, the block must also be registered and have its attributes defined in PHP.

```php
register_block_type(
'core/archives',
array(
'attributes' => array(
'showPostCounts' => array(
'type' => 'boolean',
'default' => false,
),
'displayAsDropdown' => array(
'type' => 'boolean',
'default' => false,
),
),
'render_callback' => 'render_block_core_archives',
)
);
```

0 comments on commit 0fba129

Please sign in to comment.