-
-
Notifications
You must be signed in to change notification settings - Fork 813
Description
I would like is the ability for renderers to opt-in / opt-out of being displayed as options on the page.
https://www.niche-museums.com/browse/museums for example shows a atom link because the datasette-atom plugin is installed... but clicking it will give you a 400 error because the correct columns are not present.
Here's the code that passes a list of renderers to the template:
datasette/datasette/views/base.py
Lines 411 to 423 in 2d099ad
| renderers = { | |
| key: path_with_format(request, key, {**url_labels_extra}) | |
| for key in self.ds.renderers.keys() | |
| } | |
| url_csv_args = {"_size": "max", **url_labels_extra} | |
| url_csv = path_with_format(request, "csv", url_csv_args) | |
| url_csv_path = url_csv.split("?")[0] | |
| context = { | |
| **data, | |
| **extras, | |
| **{ | |
| "renderers": renderers, | |
| "url_csv": url_csv, |
A renderer is currently defined as a two-key dictionary:
@hookimpl
def register_output_renderer(datasette):
return {
'extension': 'test',
'callback': render_test
}I can add a third key, "should_suggest" which is a function that returns True or False for a given query. If that key is missing it is assumed to return True.
One catch: what arguments should be passed to the should_suggest(...) function?
UPDATE: now calling it can_render instead.
Originally posted by @simonw in #581 (comment)
