summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2014-11-17 14:31:31 -0600
committerSol Jerome <sol.jerome@gmail.com>2014-11-17 14:31:31 -0600
commitc544b18a985edd7444593e75ad52483f4842c119 (patch)
tree6b4504ec02bcc339217dcf754ae6e51f9e697685 /doc
parentb8310f6f2b2c440704913af53b4af90b9ce13e8c (diff)
parent0512f18f11b2ba9432a8be8eb2c05b6e290b976b (diff)
downloadbcfg2-c544b18a985edd7444593e75ad52483f4842c119.tar.gz
bcfg2-c544b18a985edd7444593e75ad52483f4842c119.tar.bz2
bcfg2-c544b18a985edd7444593e75ad52483f4842c119.zip
Merge branch 'include2' of https://github.com/gordonmessmer/bcfg2
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