How to use the nunjucks/src/runtime.markSafe function in nunjucks

To help you get started, we’ve selected a few nunjucks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Snugug / gulp-armadillo / lib / helpers / nunjucks / filters / front-matter.js View on Github external
nunjucks.addFilter('body', file => {
    return r.markSafe(fm(fs.readFileSync(path.join(process.cwd(), file)).toString()).body);
  });
};
github Snugug / gulp-armadillo / lib / helpers / nunjucks / filters / markdown.js View on Github external
nunjucks.addFilter('markdown', value => {
    return r.markSafe(md.render(value));
  });
};
github Snugug / gulp-armadillo / lib / helpers / nunjucks / filters / render.js View on Github external
nunjucks.addFilter('render', file => {
    let content = fs.readFileSync(path.join(process.cwd(), file));
    const matter = fm(content.toString());
    const ext = path.extname(file);
    content = matter.body;

    if (ext === '.md' || ext === '.markdown') {
      content = md.render(content);
    }

    return r.markSafe(nunjucks.renderString(content, matter.attributes));
  });
};