'Unexpected symbol 'contains' when conditionally inserting variable template

I can't figure this one out. Any help is appreciated. This is driving me nuts, not sure what I am doing wrong.

I have tried replacing 'contains' with 'eq' and 'startsWith' but for some reason it keeps telling me its an unexpected symbol.

Exact error:

(Line: 33, Col: 3): Unexpected symbol: 'contains'. Located at position 8 within expression: elseif contains(variables['Build.SourceBranch'], 'user')

resources:
  repositories:
    - repository: WebAppComponents
      ref: main
      endpoint: RepoAccess
      type: git
      name: Project/WebAppComponents.git

    - repository: test-data
      ref: main
      endpoint: RepoAccess
      type: git
      name: Project/test-data.git


variables:
- template: Variables/default.yml
- ${{ if contains(variables['resources.repositories.WebAppComponents.ref'], 'user') }}:
  - template: Variables/dev.yml
- ${{ elseif contains(variables['Build.SourceBranch'], 'user') }}:
  - template: Variables/dev.yml
- ${{ else }}:
  - template: Variables/main.yml


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source