Jinja2 Extension for running shell commands
Project description
jinja2-shell
Jinja2 Extension for running shell commands. Makes use of subprocess.run(shell=False)
.
Installation
Install this via pip (or your favourite package manager):
pip install jinja2-shell
Usage
The extension class is jinja2_shell.ShellExtension
.
If the second argument is True
(default), the output is stripped of trailing whitespace and newlines. (a\n\b \n
-> a\nb
)
As a statement:
{% shell "echo Hello World" %}
{% shell "echo Hello World", False %}
{% shell "echo 'Hello World', False %}
{% shell "echo \"Hello World\"", False %}
Hello World
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)
As a expression:
{{ "echo Hello World" | shell }}
{{ "echo Hello World" | shell(False) }}
{{ "echo 'Hello World'" | shell(False) }}
{{ "echo \"Hello World\"" | shell(False) }
Hello World
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)
Contributors ✨
Thanks goes to these wonderful people (emoji key):
34j 💻 🤔 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jinja2_shell-0.1.4.tar.gz
.
File metadata
- Download URL: jinja2_shell-0.1.4.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.11.2 readme-renderer/44.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.67.0 importlib-metadata/8.5.0 keyring/25.5.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d772682f080648e50d3c8a59d20232e4a5a7dec9915fd726f8b20d9d0013c45b |
|
MD5 | afd70fdf3dd0eb0118ce08efb1cab8ce |
|
BLAKE2b-256 | ff61956a1b7379ca5037bd382adf01ee0420ce04a22242483808026b8c8395ce |
File details
Details for the file jinja2_shell-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: jinja2_shell-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.11.2 readme-renderer/44.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.67.0 importlib-metadata/8.5.0 keyring/25.5.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0649aaf027b29a718df9814505776b0f616371ac6a34ae70f775385ff32006b4 |
|
MD5 | ed04387411397c5eb4dcc6b5bc8a9d00 |
|
BLAKE2b-256 | c36e457c59bcba31c99ef329691f4e5ab038b72661e497ce5ddd0a16bfe81e29 |