Using go template with Kots and kustomize

Hello There,
We would like to add a block of code based on if condition. Something like we want to add a bunch of annotations only for cloud deployments like below.

apiVersion: v1
kind: Service
metadata:
  {{repl if not IsKurl}}
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'true'
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
  {{repl end}}
  labels:
    helm.sh/chart: ingress-nginx-3.30.0
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/version: 0.46.0
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: controller
  name: ingress-nginx-controller
  namespace: ingress-nginx
spec:
  type: "{{repl ternary NodePort LoadBalancer IsKurl}}"
  ports:
    - name: http
      nodePort: 80
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      nodePort: 443
      port: 443
      protocol: TCP
      targetPort: https
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/component: controller

When we tried doing that and used kustomize to build it throws validation errors. yaml: line 5: mapping values are not allowed in this context'.
Is there a way of making this work so that we can leverage the use of kots templte functions?