Refactoring of nunjucks.compat