From da1e53b1903909221f301f82e70afec6b64d5907 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 10 Sep 2019 17:54:18 +0200 Subject: [PATCH] Fixed --- Makefile | 4 +++- style.html.j2 | 2 +- style.js | 2 +- templates/card.xml.j2 | 2 +- templates/style.xsl.j2 | 40 +++++++++++++++++++++++++++------------- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 0de4d85..8f996f5 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ with open("build/card.xml", "w") as f: endef export PYTHON_MAKE_CARD_XML -build/card.xml: card.yaml +build/card.xml: card.yaml templates/card.xml.j2 python3 -c "$$PYTHON_MAKE_CARD_XML" @@ -37,6 +37,8 @@ with open("style.html.j2") as f: jinja_data = f.read() with open("style.js") as f: js_data = f.read() with open("build/style.xsl", "w") as f: f.write(Environment( + trim_blocks=True, + lstrip_blocks=True, loader=FileSystemLoader('templates')) .get_template('style.xsl.j2') .render( css_data=css_data, jinja_data=jinja_data, js_data=js_data)) diff --git a/style.html.j2 b/style.html.j2 index 77060bc..64bb1d1 100644 --- a/style.html.j2 +++ b/style.html.j2 @@ -34,7 +34,7 @@ {%- endmacro -%} -
+
{{ card.title }}
{% for figure in card.figures -%} diff --git a/style.js b/style.js index 1e1a90e..50e6cfe 100644 --- a/style.js +++ b/style.js @@ -28,4 +28,4 @@ env.addFilter('all', function(iterable) { rendered = env.renderString(jinja_template, context); console.log(rendered); -document.getElementById("my_card").innerHTML = rendered; +document.write(rendered); diff --git a/templates/card.xml.j2 b/templates/card.xml.j2 index 79cb018..aa3dbf9 100644 --- a/templates/card.xml.j2 +++ b/templates/card.xml.j2 @@ -1,3 +1,3 @@ -{{ data }} +{{ data.strip() }} diff --git a/templates/style.xsl.j2 b/templates/style.xsl.j2 index 4f6592d..559b195 100644 --- a/templates/style.xsl.j2 +++ b/templates/style.xsl.j2 @@ -1,16 +1,21 @@ - + -<!DOCTYPE html> - - {% set newline = "\n" %} {% set async = "media=\"none\" onload=\"if(media!='all')media='all'\"" %} -{% filter replace("\n", newline) %} - + + @@ -20,33 +25,42 @@ Status Card + {% endfilter %} + + {{ newline*2 }} - {{ newline*2 }} {{ newline*2 }} -
+{{ newline*2 }} + + +{{ newline }} + +