mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Expose current SQLite row to render_cell hook, closes #1300
This commit is contained in:
parent
9f1eb0d4ea
commit
6373bb3414
6 changed files with 14 additions and 7 deletions
|
|
@ -98,12 +98,13 @@ def extra_body_script(
|
|||
|
||||
|
||||
@hookimpl
|
||||
def render_cell(value, column, table, database, datasette):
|
||||
def render_cell(row, value, column, table, database, datasette):
|
||||
async def inner():
|
||||
# Render some debug output in cell with value RENDER_CELL_DEMO
|
||||
if value == "RENDER_CELL_DEMO":
|
||||
return json.dumps(
|
||||
{
|
||||
"row": dict(row),
|
||||
"column": column,
|
||||
"table": table,
|
||||
"database": database,
|
||||
|
|
|
|||
|
|
@ -181,12 +181,13 @@ def test_hook_render_cell_demo(app_client):
|
|||
response = app_client.get("/fixtures/simple_primary_key?id=4")
|
||||
soup = Soup(response.body, "html.parser")
|
||||
td = soup.find("td", {"class": "col-content"})
|
||||
assert {
|
||||
assert json.loads(td.string) == {
|
||||
"row": {"id": "4", "content": "RENDER_CELL_DEMO"},
|
||||
"column": "content",
|
||||
"table": "simple_primary_key",
|
||||
"database": "fixtures",
|
||||
"config": {"depth": "table", "special": "this-is-simple_primary_key"},
|
||||
} == json.loads(td.string)
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue