This commit is contained in:
Peder Bergebakken Sundt 2019-09-09 19:29:27 +02:00
parent 295c59689e
commit 9545b2a205
4 changed files with 25 additions and 9 deletions

View File

@ -3,7 +3,8 @@ all: build/card.html
.PHONY: dev .PHONY: dev
dev: dev:
git ls-files | entr make all git ls-files | entr bash -c "make all"
.PHONY: clean .PHONY: clean
clean: clean:
rm build/* rm build/*
@ -34,15 +35,16 @@ define PYTHON_MAKE_STYLE_XSL
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
with open("style.css") as f: css_data = f.read() with open("style.css") as f: css_data = f.read()
with open("style.html.j2") as f: jinja_data = f.read() with open("style.html.j2") as f: jinja_data = f.read()
with open("style.js") as f: js_data = f.read()
out = (Environment( out = (Environment(
loader=FileSystemLoader('templates')) loader=FileSystemLoader('templates'))
.get_template('style.xsl.j2') .get_template('style.xsl.j2')
.render( css_data=css_data, jinja_data=jinja_data)) .render( css_data=css_data, jinja_data=jinja_data, js_data=js_data))
#print(out) #print(out)
with open("build/card.xml", "w") as f: with open("build/style.xsl", "w") as f:
f.write(out) f.write(out)
endef endef
export PYTHON_MAKE_STYLE_XSL export PYTHON_MAKE_STYLE_XSL
build/style.xsl: style.css style.html.j2 build/style.xsl: style.css templates/style.xsl.j2 style.html.j2 style.js
python -c "$$PYTHON_MAKE_STYLE_XSL" python -c "$$PYTHON_MAKE_STYLE_XSL"

View File

@ -1,5 +1,9 @@
spis meg
<div class=""> <div class="">
</div> </div>

6
style.js Normal file
View File

@ -0,0 +1,6 @@
template = new plate.Template(jinja_template)
template.render({world: 'everyone'}, function(err, data) {
document.write(data);
})

View File

@ -1,16 +1,17 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" /> <xsl:output method="html" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/*"> <xsl:template match="/*">
<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt; <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;
</xsl:text> </xsl:text>
<script src="https://raw.githubusercontent.com/nodeca/js-yaml/master/dist/js-yaml.min.js"></script> <script src="https://raw.githubusercontent.com/nodeca/js-yaml/master/dist/js-yaml.min.js"></script>
<script src="http://mozilla.github.io/nunjucks/files/nunjucks.min.js"></script> <script src="https://raw.githubusercontent.com/chrisdickinson/plate/master/dist/plate.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"/> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"/>
<title>Status Card</title> <title>Status Card</title>
<style type="text/css"> <style type="text/css">
{{ css }} {{ css_data }}
</style> </style>
<script type="text/html" id="yaml_data"> <script type="text/html" id="yaml_data">
@ -19,7 +20,10 @@ xsl
<script type="text/javascript"> <script type="text/javascript">
var jinja_template = {{ jinja_data | tojson }}; var jinja_template = {{ jinja_data | tojson }};
// render this shit </script>
<script type="text/javascript">
{{ js_data }}
</script> </script>
</xsl:template> </xsl:template>