File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments