simonw / datasette-edit-templates

Plugin allowing Datasette templates to be edited within Datasette
4 stars 0 forks source link

Support for multiple template packs #5

Open simonw opened 5 months ago

simonw commented 5 months ago

Datasette 1.0 now has a plugin hook that lets you vary the Jinja environment based on the incoming request: https://docs.datasette.io/en/latest/plugin_hooks.html#jinja2-environment-from-request-datasette-request-env

I built this hook initially for Datasette Cloud, but I'm also excited about being able to serve different templates for different hosts on a single Datasette instance - so I could do things like host two custom websites on one server.

I want to use datasette-edit-templates for a feature on Datasette Cloud that lets users edit their public templates (served through name.datasette.site while not affecting their regular name.datasette.cloud site, using this hook.

I'm going to give datasette-edit-templates knowledge of multiple template packs, which I can then map to hosts using this plugin hook.

simonw commented 5 months ago

This could also support "public" v.s. "draft" templates - so you can work on a new set of templates, preview them in some way and then swap them in when they're ready.

simonw commented 5 months ago

I'm going to add a pack column to the table (ensuring it's there on startup if the table already exists) - it can be null for the default template pack.