var md = window.markdownit(); var context = { 'card' : jsyaml.load(document.getElementById("yaml_data").innerHTML), 'alert' : alert, }; var env = new nunjucks.Environment({ autoescape: true, trimBlocks: true, lstripBlocks: true, }); 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; }); rendered = env.renderString(jinja_template, context); console.log(rendered); document.write(rendered);