mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
rST fixes for register_output_renderer docs
This commit is contained in:
parent
2d099ad9c6
commit
9e6075d21f
1 changed files with 7 additions and 7 deletions
|
|
@ -743,11 +743,11 @@ Allows the plugin to register a new output renderer, to output data in a custom
|
||||||
@hookimpl
|
@hookimpl
|
||||||
def register_output_renderer(datasette):
|
def register_output_renderer(datasette):
|
||||||
return {
|
return {
|
||||||
'extension': 'test',
|
"extension": "test",
|
||||||
'callback': render_test
|
"callback": render_test
|
||||||
}
|
}
|
||||||
|
|
||||||
This will register `render_test` to be called when paths with the extension `.test` (for example `/database.test`, `/database/table.test`, or `/database/table/row.test`) are requested. When a request is received, the callback function is called with three positional arguments:
|
This will register ``render_test`` to be called when paths with the extension ``.test`` (for example ``/database.test``, ``/database/table.test``, or ``/database/table/row.test``) are requested. When a request is received, the callback function is called with three positional arguments:
|
||||||
|
|
||||||
``args`` - dictionary
|
``args`` - dictionary
|
||||||
The GET parameters of the request
|
The GET parameters of the request
|
||||||
|
|
@ -756,15 +756,15 @@ This will register `render_test` to be called when paths with the extension `.te
|
||||||
The data to be rendered
|
The data to be rendered
|
||||||
|
|
||||||
``view_name`` - string
|
``view_name`` - string
|
||||||
The name of the view where the renderer is being called. (`index`, `database`, `table`, and `row` are the most important ones.)
|
The name of the view where the renderer is being called. (``index``, ``database``, ``table``, and ``row`` are the most important ones.)
|
||||||
|
|
||||||
The callback function can return `None`, if it is unable to render the data, or a dictionary with the following keys:
|
The callback function can return ``None``, if it is unable to render the data, or a dictionary with the following keys:
|
||||||
|
|
||||||
``body`` - string or bytes, optional
|
``body`` - string or bytes, optional
|
||||||
The response body, default empty
|
The response body, default empty
|
||||||
|
|
||||||
``content_type`` - string, optional
|
``content_type`` - string, optional
|
||||||
The Content-Type header, default `text/plain`
|
The Content-Type header, default ``text/plain``
|
||||||
|
|
||||||
``status_code`` - integer, optional
|
``status_code`` - integer, optional
|
||||||
The HTTP status code, default 200
|
The HTTP status code, default 200
|
||||||
|
|
@ -775,7 +775,7 @@ A simple example of an output renderer callback function:
|
||||||
|
|
||||||
def render_test(args, data, view_name):
|
def render_test(args, data, view_name):
|
||||||
return {
|
return {
|
||||||
'body': 'Hello World'
|
"body": "Hello World"
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples: `datasette-atom <https://github.com/simonw/datasette-atom>`_, `datasette-ics <https://github.com/simonw/datasette-ics>`_
|
Examples: `datasette-atom <https://github.com/simonw/datasette-atom>`_, `datasette-ics <https://github.com/simonw/datasette-ics>`_
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue