Template IPython magics 🎩
This package provides simple IPython magics to render cells as templates in a variety of different templating languages. It currently supports Mako and Jinja2.
To use it, first install the package from PyPI, along with at least one of the supported templating languages. E.g. using pipenv (everyone should use pipenv):
pipenv install template-ipython-magic jinja2 mako
In your notebook, load the template_magic module:
%load_ext template_magic
Note that the available templating languages are detected at the point of loading the extension, and each magic only enabled if the appropriate package is found. If neither Jinja2 or Mako are installed, there will be no magics!
Now you can use %jinja as a line magic within any code block, with access to all variables in scope. The result is formatted as Markdown:
import sys
%jinja Hello from **Jinja** on Python {{sys.version_info.major}}.{{sys.version_info.minor}}! 🐍
Hello from Jinja on Python 3.8! 🐍
If you prefer, %mako is also available:
import datetime
now = datetime.datetime.now()
%mako Hello from *Mako* at ${now.strftime('%I:%M %p')}... ⏰
Hello from Mako at 08:39 PM... ⏰
Cell magics are also available for each language, which lets you render the entire cell as a template for convenient report generation:
%%jinja
{%- for x in ['spam'] * 7 + ['eggs', 'spam'] %}
- {% if loop.last %}and {% endif %}{{x}}{%if not loop.last %},{% endif %}
{%- endfor %}
- spam,
- spam,
- spam,
- spam,
- spam,
- spam,
- spam,
- eggs,
- and spam
Metadata
Release files for template-ipython-magic 0.1.2
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 |
|---|---|---|---|---|
| template-ipython-magic-0.1.2.tar.gz | 2.7 kB | Without provenance | Details for template-ipython-magic-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| template_ipython_magic-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for template_ipython_magic-0.1.2-py3-none-any.whl |
Total release size: 5.8 kB
Release files / template-ipython-magic-0.1.2.tar.gz
| Download URL | template-ipython-magic-0.1.2.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e22d8903b64f888548989d4c9b20d1d057b87880ff70c830e59e7ed30d7762f
|
|
BLAKE2b-256 checksum How to use checksums |
0b516778cd2454bc29ef02326cd867e5e6b7d56193a41d119bba7e8c2d75da58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.8.1 Linux/5.4.8-arch1-1
|
Release files / template_ipython_magic-0.1.2-py3-none-any.whl
| Download URL | template_ipython_magic-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a87ef26de4cc064ea07a8e1f7e51b12115a0326f602691a6ce069d4a7f050de
|
|
BLAKE2b-256 checksum How to use checksums |
6ff8096bbbb0804f45bc7bd7589b4da4e2f71d97add97fc8c46680c58f1233f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.8.1 Linux/5.4.8-arch1-1
|
Security for template-ipython-magic 0.1.2
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.