How to use the nunjucks/src/parser.parse 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 justrhysism / prettier-plugin-nunjucks / src / parser.js View on Github external
function parse(text) {
  const nunjParsed = nunjucks.parse(text);
  const normalised = ast.normalize(nunjParsed);
  normalised.raw = text;
  return normalised;
}
github shawnbot / meta-template / parse / index.js View on Github external
const parseString = (str, opts) => {
  if (opts && opts.trim === true) {
    str = str.trim();
  }
  var node = ast.normalize(parser.parse(str));
  if (opts && opts.verbose) {
    node = ast.walk(node, n => {
      n.parent = n.parent ? n.parent.type : null
    });
  } else if (opts && opts.clean === true) {
    node = ast.clean(node);
  }
  return node;
};