-
-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utility mechanism for plugins to render templates #577
Comments
Here's the horrific (stack inspecting) workaround I came up with for a prototype of |
I think a |
Better idea: take advantage of pluggy dependency injection. If a plugin takes a The need to |
I'm going to go with |
The reason I've been dragging my heels on adding template rendering to the Datasette class is that it feels messy - should that class be responsible for both data access AND template rendering? I think I can come to terms with this thanks to plugins. The Datasette class can represent the family of features that plugins affect - which means that having it expose the template rendering API is reasonable. |
The code in question currently lives in datasette/datasette/views/base.py Lines 106 to 163 in d54318f
Should Plugins need the option to not pass a Perhaps plugins should be able to render templates without other plugins getting to inject their own variables? Does it always make sense to dump in all of those extra template context variables? |
For the moment I'm going to move it to The new signature will be:
I'll reconsider the large list of default context variables later on in a separate ticket. |
Also improved parameter documentation for other methods, refs #576
Sometimes a plugin will need to render a template for some custom UI. We need a documented API for doing this, which ensures that everything will work correctly if you extend base.html etc.
See also #576. This could be a
.render()
method on the Datasette class, but that feels a bit weird - should that class also take responsibility for rendering?The text was updated successfully, but these errors were encountered: