simonw / datasette

An open source multi-tool for exploring and publishing data
https://datasette.io
Apache License 2.0
9.48k stars 680 forks source link

render_cell(value) plugin hook #352

Closed simonw closed 6 years ago

simonw commented 6 years ago

To allow plugins to customize how values matching a specific pattern are displayed in the HTML table view.

simonw commented 6 years ago

The hook is currently only used on the custom SQL results page - it needs to run on table/view pages as well.

simonw commented 6 years ago

First plugin using this hook: https://github.com/simonw/datasette-json-html

Hook documentation: http://datasette.readthedocs.io/en/latest/plugins.html#render-cell-value

simonw commented 6 years ago

I used datasette-json-html to build this: https://russian-ira-facebook-ads-datasette-whmbonekoj.now.sh/russian-ads-919cbfd/display_ads

xrotwang commented 4 years ago

I don't want to re-open this issue, but I'm wondering whether it would be possible to include the full row for which a specific cell is to be rendered in the hook signature. My use case are rows where custom rendering would need access to multiple values (specifically, rows containing the constituents of interlinear glossed text (IGT) in separate columns, see https://github.com/cldf/cldf/tree/master/components/examples).

I could probably cobble this together with custom SQL and the sql-to-html plugin. But having a full row within a render_cell implementation seems a lot simpler.