django-template-standalone
Simple setup to use django's template engine for non-django applications.
Install
pip install django-template-standalone
Usage
from django_template_standalone import render
from django_template_standalone import register_dirs
from django_template_standalone import render_template
msg = render("hello {{name}}, how are you?", {"name": "Cissie"})
assert msg == "hello Cissie, how are you?"
reigster_dirs("./templates/")
html = render_template("index.html", {"title": "This is an index Page"})
assert html == "<h1>This is an index Page</h1>"
Content of ./templates/index.html is:
<h1>{{title}}</h1>
Methods
render(template_text, context): Render a template text with context.render_template(template_filename, context): Render a template file with context.reigster_dirs(*dirs): Add template dirs.register_apps(*apps): Add template apps.setup(template_dirs, apps): Setup django's template engine with template dirs and apps.
Note:
- When using
reigster_appsmethod or usingappsparameter insetupmethod, there must be atemplatessub-folder under the APP's root folder. - The
setupmethod will be auto called in other functions, so you really don't need to call it manually.
Releases
v0.1.0 2021/11/30
- First release.
Metadata
Release files for django-template-standalone 0.1.0
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 |
|---|---|---|---|---|
| django-template-standalone-0.1.0.tar.gz | 4.3 kB | Without provenance | Details for django-template-standalone-0.1.0.tar.gz |
Release files / django-template-standalone-0.1.0.tar.gz
| Download URL | django-template-standalone-0.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0447fb8ae20af4a9d8a5de701b303fc9f1b8f37d78105994fe73956e553bc16a
|
|
BLAKE2b-256 checksum How to use checksums |
e0a09fcbb87aee59f3628ca9b0aee081b76b7ea2222b2dc191262dfe175e439c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for django-template-standalone 0.1.0
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.