New plugin hook: extra_body_script

This commit is contained in:
Simon Willison 2018-08-28 01:56:44 -07:00
commit 5cf0c6c91c
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
6 changed files with 88 additions and 0 deletions

View file

@ -222,6 +222,23 @@ def extra_js_urls():
'url': 'https://example.com/jquery.js',
'sri': 'SRIHASH',
}, 'https://example.com/plugin1.js']
@hookimpl
def extra_body_script(template, database, table, datasette):
import json
return 'var extra_body_script = {};'.format(
json.dumps({
"template": template,
"database": database,
"table": table,
"config": datasette.plugin_config(
"name-of-plugin",
database=database,
table=table,
)
})
)
'''
PLUGIN2 = '''