Pass list of card configs to script variable

Hi

I have a script that shows a browser_mod popup with a camera feed and I’m trying to configure the script so you can optionally pass in extra cards to display in the popup but I can’t figure out how to do this.

The current script is below. I’m trying to pass additional cards in the overlay_cards variable and have it added to the grid layout in the popup.

Does anyone know how to do this please?

lovelace_show_camera_popup:
  mode: single
  fields:
    browser_id:
      selector:
        text:
          multiple: true
      name: Browser ID
      required: true
    url:
      selector:
        text:
      name: url
      required: true
    overlay_cards:
      selector:
        object:
      name: Overlay card
  sequence:
    - variables:
        content:
          type: custom:layout-card
          layout_type: custom:grid-layout
          layout:
            margin: 0
          cards:
          - type: custom:webrtc-camera
            url: '{{url}}'
            view_layout:
              grid-area: 1 / 1
          {{overlay_cards}} <-- This doesn't work here
    - action: browser_mod.popup
      data:
        browser_id: '{{browser_id}}'
        dismissable: true
        autoclose: false
        size: fullscreen
        content: '{{content}}'

ChatGPT had the answer. Turns out you can simply append the cards together in a template.

content:
    type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      margin: 0
    cards: "{{ camera_card + overlay_cards | default([]) }}"

camera_card is a variable in the script for the webrtc-camera card. overlay_cards is the script field where you can pass in additional cards.