diff --git a/templating/build.py b/templating/build.py index 78e48b02..7752f309 100755 --- a/templating/build.py +++ b/templating/build.py @@ -66,8 +66,12 @@ def check_unaccessed(name, store): def main(): # add a template filter to produce pretty pretty JSON - def jsonify(input): - return json.dumps(input, indent=4) + def jsonify(input, pre_whitespace=0): + code = json.dumps(input, indent=4) + if pre_whitespace: + code = code.replace("\n", ("\n" +" "*pre_whitespace)) + + return code # make Jinja aware of the templates and filters env = Environment( diff --git a/templating/templates/events.tmpl b/templating/templates/events.tmpl index fa70e5eb..602aa108 100644 --- a/templating/templates/events.tmpl +++ b/templating/templates/events.tmpl @@ -1,7 +1,15 @@ -{{event.type}} --------------- -Summary: {{event.summary}} -Type: {{event.typeof}} -Description: {{event.desc}} -JSON Format: {{event.json_format | jsonify}} -Example: {{example.content | jsonify}} +``{{event.type}}`` + Summary: + {{event.summary}} + Type: + {{event.typeof}} + Description: + {{event.desc}} + + JSON Format:: + + {{event.json_format | jsonify(4)}} + + Example:: + + {{example.content | jsonify(4)}}