Member Junction
    Preparing search index...

    Function AssertTemplateTreeIsSafe

    • Checks a parsed nunjucks template, and throws a TemplateSandboxError if a name in it could change the code the compiler generates:

      • every variable, filter, loop, set, macro, import and block name must be a plain name (letters, combining marks, digits, connector punctuation such as _, and $); a filter name can also contain dots
      • a test name, and an extension's registered name and method, must not contain a quote, a backslash or a line break
      • a name that every object inherits (toString, hasOwnProperty, ...), or prototype, must not be a dictionary key, a keyword argument, a macro or call-block argument, a set, loop, import, macro or block name, or a filter or test name
      • the name of a called member must not contain a backslash or a line break
      • a loop variable must not reuse an identifier that the generated loop code uses (context, frame, runtime, tasks, undefined, ...)
      • the tree must hold only nunjucks nodes, plain values and regular expression literals

      Parameters

      • tree: unknown

        the root node the nunjucks parser returns

      Returns void