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
  {{repl if not IsKurl}}
  annotations: tcp 'true' nlb
  {{repl end}}
  labels: ingress-nginx-3.30.0 ingress-nginx ingress-nginx 0.46.0 Helm controller
  name: ingress-nginx-controller
  namespace: ingress-nginx
  type: "{{repl ternary NodePort LoadBalancer IsKurl}}"
    - name: http
      nodePort: 80
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      nodePort: 443
      port: 443
      protocol: TCP
      targetPort: https
  selector: ingress-nginx ingress-nginx 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?