From 295c59689ed299db75f192c7e2e9f023ed7268d1 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Mon, 9 Sep 2019 19:07:05 +0200 Subject: [PATCH] asd --- Makefile | 76 +++++++++++++----------- templates/{style.xls.j2 => style.xsl.j2} | 5 +- 2 files changed, 44 insertions(+), 37 deletions(-) rename templates/{style.xls.j2 => style.xsl.j2} (90%) diff --git a/Makefile b/Makefile index cc99b3b..f32093a 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,48 @@ -all: build/out.html - -build/out.html: card.yaml build/card.xml build/style.xsl style.css - xsltproc \ - -o build/out.html \ - build/style.xsl \ - build/card.xml - - -define TMP_PYTHON_PROG -from jinja2 import Environment, FileSystemLoader - -with open("card.yaml") as f: - data = f.read() - -out = Environment( - loader=FileSystemLoader('templates'))\ - .get_template('card.xml.j2')\ - .render(data=data) - -#print(out) - -with open("build/card.xml", "w") as f: - f.write(out) -endef - -export TMP_PYTHON_PROG -build/card.xml: - python -c "$$TMP_PYTHON_PROG" - -build/style.xsl: style.html.j2 - cp style.html.j2 build/style.xsl - +all: build/card.html .PHONY: dev dev: git ls-files | entr make all - .PHONY: clean clean: - rm build/* out.html + rm build/* + +build/card.html: build/card.xml build/style.xsl + xsltproc \ + -o build/card.html \ + build/style.xsl \ + build/card.xml + +define PYTHON_MAKE_CARD_XML +from jinja2 import Environment, FileSystemLoader +with open("card.yaml") as f: data = f.read() +out = (Environment( + loader=FileSystemLoader('templates')) + .get_template('card.xml.j2') + .render(data=data)) +with open("build/card.xml", "w") as f: + f.write(out) +endef + +export PYTHON_MAKE_CARD_XML +build/card.xml: card.yaml + python -c "$$PYTHON_MAKE_CARD_XML" + + +define PYTHON_MAKE_STYLE_XSL +from jinja2 import Environment, FileSystemLoader +with open("style.css") as f: css_data = f.read() +with open("style.html.j2") as f: jinja_data = f.read() +out = (Environment( + loader=FileSystemLoader('templates')) + .get_template('style.xsl.j2') + .render( css_data=css_data, jinja_data=jinja_data)) +#print(out) +with open("build/card.xml", "w") as f: + f.write(out) +endef + +export PYTHON_MAKE_STYLE_XSL +build/style.xsl: style.css style.html.j2 + python -c "$$PYTHON_MAKE_STYLE_XSL" diff --git a/templates/style.xls.j2 b/templates/style.xsl.j2 similarity index 90% rename from templates/style.xls.j2 rename to templates/style.xsl.j2 index 94eaab5..fdbe649 100644 --- a/templates/style.xls.j2 +++ b/templates/style.xsl.j2 @@ -14,11 +14,12 @@