Utility mechanism for plugins to render templates
See original GitHub issueSometimes 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?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Plugins — Airflow Documentation
A web server you can use to render your views. A metadata database to store your models. Access to your databases, and knowledge...
Read more >The only Figma plugins you need for your workflow - UX Planet
The plugin offers different chart templates with great visual styling. It can generate random data with different distribution types as per your ...
Read more >Connect your theme to plugin-outlets to inject templates with ...
When injecting HTML into your page you can also inject templates, this gives you a very simple mechanism for injecting content into various...
Read more >Plugins — CrafterCMS 4.0.2 documentation
CrafterCMS provides a mechanism (a “hook”) for adding markup and defining macros for plugins via Freemarker templates. These templates, when the plugin has ......
Read more >dev Plugin - DokuWiki
This command line plugin helps plugin and template developers dealing with the boilerplate required. It can be used to create and extend ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the moment I’m going to move it to
async def render_template()
ondatasette
but otherwise keep the implementation the same.The new signature will be:
template
can be a list of strings or a single string. If a list of strings a template will be selected from them.I’ll reconsider the large list of default context variables later on in a separate ticket.
The code in question currently lives in
BaseView.render()
:https://github.com/simonw/datasette/blob/d54318fc7f2565e6121920ce1ea9cb8b700e629a/datasette/views/base.py#L106-L163
Should
datasette.render_template()
do exactly this, or should it be slightly different?Plugins need the option to not pass a
request
object - so maybe that parameter becomes optional.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?