Selectively switch web server version based on platform or board?

I split out the yaml that’s repeated across multiple esphome devices into separate files and then include them using something like this:

packages:
  logger: !include common/logger.yaml
  api_ota: !include common/api_ota.yaml
  wifi: !include common/wifi.yaml
  web_server: !include common/web_server.yaml

With web_server: though, I’d like to include either version: 2 or version: 3 depending on whether the board uses esp8266: or esp32:.

Does anyone know a way to include some simple logic in my web_server.yaml, along the lines of either

if (platform == esp32) {
     version: 3
    } else {
     version: 2
    }

or

if (platform == esp32) {version: 3}
if (platform == esp8266) {version: 2}

please?
Thanks!

No.

Can create two packages: one for esp32, another fr esp8266 with appropriate web servers versions.

Can and already have. Was just wondering, to learn more than for any practical reason.