Skip to content
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

Ability for plugins to bundle templates #224

Closed
simonw opened this issue Apr 18, 2018 · 1 comment
Closed

Ability for plugins to bundle templates #224

simonw opened this issue Apr 18, 2018 · 1 comment
Labels

Comments

@simonw
Copy link
Owner

simonw commented Apr 18, 2018

Plugins should be able to bundle templates.

The Datasette template loader should then consult those plugins first when loading a template.

Jinja2 has a PackageLoader class that can help with this: http://jinja.pocoo.org/docs/2.10/api/#jinja2.PackageLoader

Refs #14

@simonw simonw added the plugins label Apr 18, 2018
@simonw
Copy link
Owner Author

simonw commented Apr 19, 2018

No need to use PackageLoader after all, we can use the same mechanism we used for the static path:

if pkg_resources.resource_isdir(plugin.__name__, 'static'):
static_path = pkg_resources.resource_filename(plugin.__name__, 'static')

simonw pushed a commit to simonw/datasette-plugin-demos that referenced this issue Apr 19, 2018
@simonw simonw closed this as completed in b52171d Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant