2019-09-10 00:52:30 +02:00
|
|
|
var md = window.markdownit();
|
|
|
|
var context = {
|
|
|
|
'card' : jsyaml.load(document.getElementById("yaml_data").innerHTML),
|
|
|
|
'alert' : alert,
|
|
|
|
};
|
2019-09-09 19:29:27 +02:00
|
|
|
|
2019-09-10 00:52:30 +02:00
|
|
|
var env = new nunjucks.Environment({
|
2019-09-11 05:09:42 +02:00
|
|
|
autoescape: true,
|
|
|
|
trimBlocks: true,
|
|
|
|
lstripBlocks: true,
|
2019-09-10 00:52:30 +02:00
|
|
|
});
|
|
|
|
env.addFilter('markdown', function(str) {
|
|
|
|
return md.render(str);
|
|
|
|
});
|
|
|
|
env.addFilter('cull_whitespace', function(str) {
|
|
|
|
return str.split(/\s+/).join(' ').trim();
|
|
|
|
});
|
|
|
|
env.addFilter('any', function(iterable) {
|
|
|
|
for (var index = 0; index < iterable.length; index++) {
|
|
|
|
if (iterable[index]) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
env.addFilter('all', function(iterable) {
|
|
|
|
for (var index = 0; index < iterable.length; index++) {
|
|
|
|
if (!iterable[index]) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
2019-09-09 19:29:27 +02:00
|
|
|
|
2019-09-10 00:52:30 +02:00
|
|
|
rendered = env.renderString(jinja_template, context);
|
|
|
|
console.log(rendered);
|
2019-09-10 17:54:18 +02:00
|
|
|
document.write(rendered);
|