Skip to content

Commit c509ddd

Browse files
committed
chore: sync common files from resources repository
1 parent afbf05d commit c509ddd

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@
1212

1313
[//]: # (TABLE_OF_CONTENTS_PLACEHOLDER)
1414

15+
## What is it ?
16+
17+
This is a [jinja2](http://jinja.pocoo.org/) extension to execute system/shell
18+
commands from a template.
19+
20+
**WARNING: be sure to valid any string submitted to this filter as you can
21+
open security holes with it**
22+
23+
## Syntax
24+
25+
The syntax is `'full_command_with_args'|shell([die_on_error_boolean_flag], [encoding])`.
26+
27+
## Example
28+
29+
```python
30+
31+
from jinja2 import Template, Environment
32+
33+
# We load the extension in a jinja2 Environment
34+
env = Environment(extensions=["jinja2_shell_extension.ShellExtension"])
35+
36+
# For the example, we use a template from a simple string
37+
template = env.from_string("{{ 'date --rfc-2822'|shell() }}")
38+
result = template.render()
39+
40+
# example: result == "Fri, 31 Jan 2020 13:35:56 +0100"
41+
# [...]
42+
43+
```
1544

1645

1746

0 commit comments

Comments
 (0)