From 0ba6b9a8663df6b37ccf45edd8d8f75ef3521a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=20Nam=C3=A8che?= Date: Thu, 22 Jan 2026 08:54:47 +0300 Subject: [PATCH] dict2str: filter documentation --- seb4itik/byow/plugins/filter/dic2str.py | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/seb4itik/byow/plugins/filter/dic2str.py b/seb4itik/byow/plugins/filter/dic2str.py index 1f2f235..05e1e2c 100644 --- a/seb4itik/byow/plugins/filter/dic2str.py +++ b/seb4itik/byow/plugins/filter/dic2str.py @@ -10,3 +10,42 @@ class FilterModule(object): return sep2.join( [ str(k) + (sep1+str(v) if v!=None and v!='' else '') for k, v in d.items() ] ) + sep3 + + +DOCUMENTATION = """ + name: dict2str + author: Sébastien Namèche (@seb4itik) + version_added: "0.1.1" + short_description: This filter transforms a flat dict into a string using 3 separators. + description: + - If my_dict is {one: "un", two: "deux", three: "trois"}, then: + - {{ my_dict | dict2str(sep1=' is ', sep2=', ', sep3='.') }} + - will produce: + - "one is un, two is deux, three is trois." + options: + sep1: + description: + - separator between each key and value pairs of the dict + type: str + default: "=" + sep2: + description: + - separator between key/value pairs of the dict that has been combined with sep1 + type: str + default: ";" + sep3: + description: + - unique final separator at the end of string + type: str + default: "" + notes: + - If a value associated to a key of the dict is None or an empty string, + - sep2 will not be used. +""" + +RETURN = """ + data: + type: str + description: + - String representating the dict using provided separators. +""" \ No newline at end of file