@@ -1979,11 +1979,120 @@ the cloud profile or master config file, no templating will be performed.
1979
1979
1980
1980
userdata_template : jinja
1981
1981
1982
+ .. conf_master :: jinja_env
1983
+
1984
+ ``jinja_env ``
1985
+ -------------
1986
+
1987
+ .. versionadded :: Oxygen
1988
+
1989
+ Default: ``{} ``
1990
+
1991
+ jinja_env overrides the default Jinja environment options for
1992
+ **all templates except sls templates **.
1993
+ To set the options for sls templates use :conf_master: `jinja_sls_env `.
1994
+
1995
+ .. note ::
1996
+
1997
+ The `Jinja2 Environment documentation <http://jinja.pocoo.org/docs/api/#jinja2.Environment >`_ is the official source for the default values.
1998
+ Not all the options listed in the jinja documentation can be overridden using :conf_master: `jinja_env ` or :conf_master: `jinja_sls_env `.
1999
+
2000
+ The default options are:
2001
+
2002
+ .. code-block :: yaml
2003
+
2004
+ jinja_env :
2005
+ block_start_string : ' {%'
2006
+ block_end_string : ' %}'
2007
+ variable_start_string : ' {{'
2008
+ variable_end_string : ' }}'
2009
+ comment_start_string : ' {#'
2010
+ comment_end_string : ' #}'
2011
+ line_statement_prefix :
2012
+ line_comment_prefix :
2013
+ trim_blocks : False
2014
+ lstrip_blocks : False
2015
+ newline_sequence : ' \n'
2016
+ keep_trailing_newline : False
2017
+
2018
+ .. conf_master :: jinja_sls_env
2019
+
2020
+ ``jinja_sls_env ``
2021
+ -----------------
2022
+
2023
+ .. versionadded :: Oxygen
2024
+
2025
+ Default: ``{} ``
2026
+
2027
+ jinja_sls_env sets the Jinja environment options for **sls templates **.
2028
+ The defaults and accepted options are exactly the same as they are
2029
+ for :conf_master: `jinja_env `.
2030
+
2031
+ The default options are:
2032
+
2033
+ .. code-block :: yaml
2034
+
2035
+ jinja_sls_env :
2036
+ block_start_string : ' {%'
2037
+ block_end_string : ' %}'
2038
+ variable_start_string : ' {{'
2039
+ variable_end_string : ' }}'
2040
+ comment_start_string : ' {#'
2041
+ comment_end_string : ' #}'
2042
+ line_statement_prefix :
2043
+ line_comment_prefix :
2044
+ trim_blocks : False
2045
+ lstrip_blocks : False
2046
+ newline_sequence : ' \n'
2047
+ keep_trailing_newline : False
2048
+
2049
+ Example using line statements and line comments to increase ease of use:
2050
+
2051
+ If your configuration options are
2052
+
2053
+ .. code-block :: yaml
2054
+ jinja_sls_env :
2055
+ line_statement_prefix : ' %'
2056
+ line_comment_prefix : ' ##'
2057
+
2058
+ With these options jinja will interpret anything after a ``% `` at the start of a line (ignoreing whitespace)
2059
+ as a jinja statement and will interpret anything after a ``## `` as a comment.
2060
+
2061
+ This allows the following more convenient syntax to be used:
2062
+
2063
+ .. code-block :: yaml
2064
+
2065
+ # # (this comment will not stay once rendered)
2066
+ # (this comment remains in the rendered template)
2067
+ # # ensure all the formula services are running
2068
+ % for service in formula_services:
2069
+ enable_service_{{ serivce }} :
2070
+ service.running :
2071
+ name : {{ service }}
2072
+ % endfor
2073
+
2074
+ The following less convenient but equivalent syntax would have to
2075
+ be used if you had not set the line_statement and line_comment options:
2076
+
2077
+ .. code-block :: yaml
2078
+
2079
+ {# (this comment will not stay once rendered) # }
2080
+ # (this comment remains in the rendered template)
2081
+ {# ensure all the formula services are running # }
2082
+ {% for service in formula_services %}
2083
+ enable_service_{{ service }} :
2084
+ service.running :
2085
+ name : {{ service }}
2086
+ {% endfor %}
2087
+
1982
2088
.. conf_master :: jinja_trim_blocks
1983
2089
1984
2090
``jinja_trim_blocks ``
1985
2091
---------------------
1986
2092
2093
+ .. deprecated :: Oxygen
2094
+ Replaced by :conf_master: `jinja_env ` and :conf_master: `jinja_sls_env `
2095
+
1987
2096
.. versionadded :: 2014.1.0
1988
2097
1989
2098
Default: ``False ``
@@ -2001,6 +2110,9 @@ to the Jinja environment init variable ``trim_blocks``.
2001
2110
``jinja_lstrip_blocks ``
2002
2111
-----------------------
2003
2112
2113
+ .. deprecated :: Oxygen
2114
+ Replaced by :conf_master: `jinja_env ` and :conf_master: `jinja_sls_env `
2115
+
2004
2116
.. versionadded :: 2014.1.0
2005
2117
2006
2118
Default: ``False ``
0 commit comments