JSONite - The Python-to-Javascript variable transformer for Masonite
This package is intended to be used alongside the Masonite Framework and allows you to pass Python variables to your base template. If no data is passed to the Javascript object on a particular request then the object returns an empty string, else it returns a JSON object featuring the passed data.
Installation:
JSONite can be installed in your Masonite project's home directory with pip:
pip install JSONite
Setup
After installing JSONite, you'll need to add the JavascriptProvider to your application providers in config/providers.py.
# config/providers.py
# ...
from jsonite import JavascriptProvider
# ...
PROVIDERS = [
# ...
# Third Party Providers
JavascriptProvider,
# ...
]
After adding the provider, you'll need to add the JavascripMiddleware class to config/middleware.py.
# config/middleware.py
# ...
from jsonite import JavascriptMiddleware
# ...
HTTP_MIDDLEWARE = [
# ...
JavascriptMiddleware,
]
# ...
Lastly, you'll want to add the line that actually renders the Javascript in your base.html file. By default the function name will be javascript_data(), but you can customize this by setting the desired value to the environment variable JS_TEMPLATE_VAR in your .env file.
<!-- template/base.html -->
<DOCTYPE html>
<html>
<!-- ... -->
<body>
<!-- ... -->
{{ javascript_data() }}
<!-- ... -->
</body>
</html>
Metadata
Release files for JSONite 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| JSONite-0.0.3.tar.gz | 3.5 kB | Without provenance | Details for JSONite-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| JSONite-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for JSONite-0.0.3-py3-none-any.whl |
Total release size: 8.8 kB
Release files / JSONite-0.0.3.tar.gz
| Download URL | JSONite-0.0.3.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9950ee5fadd7e9dbd33d59c22dd945d57cadaa2e123f26538872e1956933d034
|
|
BLAKE2b-256 checksum How to use checksums |
052c3e2902711a1461a42689068e0137a7ca0e4d10fbe9799e2a1601e4f69db9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / JSONite-0.0.3-py3-none-any.whl
| Download URL | JSONite-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cce6f474dd02d7b3f552cdeca5cb64445d3d17acef5946adec68ad59ee3f4d12
|
|
BLAKE2b-256 checksum How to use checksums |
8650568c82d687bb96529ea26076ece1000de780d6f2d83e120f1674084d99f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for JSONite 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.