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 youknowriad committed Jan 9, 2019
1 parent e452ad5 commit 23db8aa
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 23db8aa

Please sign in to comment.