Add 'toyaml()' jinja2 function

Syntax is like for built-in 'indent' filter, but must be used as
function:

{{ toyaml(data, width=0, indentfirst=False) }}

Change-Id: I067062f03a77af20c40641056d2d5e15b2c0ef09
diff --git a/reclass_tools/create_inventory.py b/reclass_tools/create_inventory.py
index 9b03632..f08fafe 100644
--- a/reclass_tools/create_inventory.py
+++ b/reclass_tools/create_inventory.py
@@ -90,10 +90,19 @@
                           Merge of the files usind update() into a single
                           dict is in the same order as files in the list.
     """
+    def toyaml(value, width=0, indentfirst=False):
+        string = yaml.dump(value, default_flow_style=False)
+        if string.splitlines():
+            return (
+                ' ' * width * indentfirst +
+                ('\n' + ' ' * width).join(string.splitlines()) + '\n')
+        else:
+            return ''
 
     overwrite_if_exists = True
 
     merged_context = {}
+
     for fcon in contexts:
         if fcon.endswith('.yaml'):
             context = helpers.yaml_read(fcon)
@@ -104,6 +113,8 @@
 
         merged_context = helpers.merge_nested_objects(merged_context, context)
 
+    merged_context['toyaml'] = toyaml
+
     try:
         generate.generate_files(
             repo_dir=template_dir,