summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorGordon Messmer <gordon@dragonsdawn.net>2014-11-17 11:04:22 -0800
committerGordon Messmer <gordon@dragonsdawn.net>2014-11-17 11:04:22 -0800
commit0512f18f11b2ba9432a8be8eb2c05b6e290b976b (patch)
treefd5f36b80134e9162646b7ff78c393e991fb04e4 /doc
parent68428631ccc90f5a973b301c31105b0444f5a8ea (diff)
downloadbcfg2-0512f18f11b2ba9432a8be8eb2c05b6e290b976b.tar.gz
bcfg2-0512f18f11b2ba9432a8be8eb2c05b6e290b976b.tar.bz2
bcfg2-0512f18f11b2ba9432a8be8eb2c05b6e290b976b.zip
Add examples for the "include" and "extends" tags in Jinja2.
Diffstat (limited to 'doc')
-rw-r--r--doc/server/plugins/generators/examples/jinja2/extends.txt61
-rw-r--r--doc/server/plugins/generators/examples/jinja2/include.txt54
2 files changed, 115 insertions, 0 deletions
diff --git a/doc/server/plugins/generators/examples/jinja2/extends.txt b/doc/server/plugins/generators/examples/jinja2/extends.txt
new file mode 100644
index 000000000..a0eeb5c03
--- /dev/null
+++ b/doc/server/plugins/generators/examples/jinja2/extends.txt
@@ -0,0 +1,61 @@
+.. -*- mode: 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
diff --git a/doc/server/plugins/generators/examples/jinja2/include.txt b/doc/server/plugins/generators/examples/jinja2/include.txt
new file mode 100644
index 000000000..49be7c277
--- /dev/null
+++ b/doc/server/plugins/generators/examples/jinja2/include.txt
@@ -0,0 +1,54 @@
+.. -*- mode: rst -*-
+
+=========================
+ Including Jinja2 Templates
+=========================
+
+Jinja2 templates can use the {% include %} directive to include file
+fragments which might be common to many configuration files.
+
+Use the "jinja2_include" suffix for file fragments you will include.
+
+``/var/lib/bcfg2/Cfg/foo/foo.jinja2``
+
+.. code-block:: none
+
+ [global]
+ setting1 = true
+ setting2 = false
+
+ {% for x in metadata.groups %}{% include x + '.jinja2_include' ignore missing %}
+ {% endfor %}
+
+``/var/lib/bcfg2/Cfg/foo/group1.jinja2_include``
+
+.. code-block:: none
+
+ [group1]
+ setting3 = true
+ setting4 = false
+
+``/var/lib/bcfg2/Cfg/foo/group3.jinja2_include``
+
+.. code-block:: none
+
+ [group3]
+ setting7 = true
+ setting8 = false
+
+Output
+======
+
+.. code-block:: none
+
+ [global]
+ setting1 = true
+ setting2 = false
+
+ [group1]
+ setting3 = true
+ setting4 = false
+
+ [group3]
+ setting7 = true
+ setting8 = false