code: private static IfNode createCspInjection(
        SourceLocation insertionLocation, IdGenerator nodeIdGen, TemplateParam defn) {
      IfNode ifNode = new IfNode(nodeIdGen.genId(), insertionLocation);
      IfCondNode ifCondNode =
          new IfCondNode(
              nodeIdGen.genId(), insertionLocation, "if", referenceCspNonce(insertionLocation, defn));
      ifNode.addChild(ifCondNode);
      HtmlAttributeNode nonceAttribute =
          new HtmlAttributeNode(
              nodeIdGen.genId(), insertionLocation, insertionLocation.getBeginPoint());
      ifCondNode.addChild(nonceAttribute);
      nonceAttribute.addChild(new RawTextNode(nodeIdGen.genId(), "nonce", insertionLocation));
      HtmlAttributeValueNode attributeValue =
          new HtmlAttributeValueNode(
              nodeIdGen.genId(), insertionLocation, HtmlAttributeValueNode.Quotes.DOUBLE);
      nonceAttribute.addChild(attributeValue);
      // NOTE: we do not need to insert any print directives here, unlike the old implementation since
      // we are running before the autoescaper, so the escaper should insert whatever print directives
      // are appropriate.
      PrintNode printNode =
          new PrintNode(
              nodeIdGen.genId(),
              insertionLocation,
              /* isImplicit= */ true, // Implicit.  {$csp_nonce} not {print $csp_nonce}
              referenceCspNonce(insertionLocation, defn),
              /* attributes= */ ImmutableList.of(),
              ErrorReporter.exploding());
      attributeValue.addChild(printNode);
      return ifNode;
    }
docs: Generates an AST fragment that looks like: {if $csp_nonce} nonce="{$csp_nonce}"{/if}
  
  @param insertionLocation The location where it is being inserted
  @param nodeIdGen The id generator to use