datasette-template-request by simonw

81 downloads this week        Star

README source code

datasette-template-request

PyPI Changelog Tests License

Expose the Datasette request object to custom templates

Installation

Install this plugin in the same environment as Datasette.

$ datasette install datasette-template-request

Usage

Once this plugin is installed, Datasette custom templates can use {{ request }} to access the current request object. For example, to access ?name=Cleo in the query string a template could use this:

Name: {{ request.args.name }}

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-template-request
python3 -mvenv venv
source venv/bin/activate

Or if you are using pipenv:

pipenv shell

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest