File tree Expand file tree Collapse file tree 1 file changed +0
-31
lines changed
Expand file tree Collapse file tree 1 file changed +0
-31
lines changed Original file line number Diff line number Diff line change 1212
1313
1414
15- ## What is it ?
16-
17- This is a [ jinja2] ( http://jinja.pocoo.org/ ) extension to access to system
18- environment variables. It is usefull if you have dynamically generated
19- variable names.
20-
21- ## Syntax
22-
23- The syntax is ` {{ 'ENV_VAR'|getenv }} ` to access to the ` ENV_VAR ` environment
24- variable. Don't forget the quotes around ` ENV_VAR ` !
25-
26- If you want to provide a default value to avoid an exception if the corresponding
27- environment variable does not exist, you can use the following syntax:
28- ` {{ 'ENV_VAR'|getenv('default_value') }} ` .
29-
30- ## Examples
31-
32- ``` python
33-
34- from jinja2 import Template, Environment
35-
36- # We load the extension in a jinja2 Environment
37- env = Environment(extensions = [" jinja2_getenv_extension.GetenvExtension" ])
38-
39- # For the example, we use a template from a simple string
40- template = env.from_string(" the value of HOME environment variable is: "
41- " {{ 'HOME'|getenv }} " )
42- result = template.render()
43-
44- # [...]
45- ```
4615
4716
4817
You can’t perform that action at this time.
0 commit comments