blob: 3c6dd06ab864816f63f6024f7f28bd6cba61e245 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
.. -*- mode: rst -*-
.. vim: ft=rst
===========================
Extending Jinja2 Templates
===========================
Jinja2 templates can use the {% extends %} directive to inherit file
fragments which might be common to many configuration files.
Use the "jinja2_include" suffix for file fragments you will extend.
``/var/lib/bcfg2/Cfg/foo/common.jinja2_include``
.. code-block:: none
[global]
setting1 = true
setting2 = false
{% block setting3 %}setting3 = "default value"{% endblock %}
{% block section1 -%}
[section1]
setting4 = true
setting5 = false
{%- endblock %}
{% block section2 -%}
[section2]
setting6 = true
setting7 = false
{%- endblock %}
``/var/lib/bcfg2/Cfg/foo/foo.H_hostname.jinja2``
.. code-block:: none
{% extends "common.jinja2_include" %}
{% block setting3 %}setting3 = "new value"{% endblock %}
{% block section1 -%}
[section1]
setting4 = false
setting5 = false
{%- endblock %}
Output
======
.. code-block:: none
[global]
setting1 = true
setting2 = false
setting3 = "new value"
[section1]
setting4 = false
setting5 = false
[section2]
setting6 = true
setting7 = false
|