Template variable expansion in Explore link

I’m developing a custom log datasource plugin. I’ve successfully added template variable expansion by following this guide: Add support for variables | Grafana Plugin Tools. This works when I use the datasource plugin in conjunction with a Logs panel on a dashboard.

However, I’d like users to be able to use the Explore context menu link to go from the Logs panel to the Explore UI. Template variables are not expanded when following the Explore link. In the Explore UI, the pre-populated query remains untemplated: service=${service}, env=${env} (service and env being the template variables that I’d like to have expanded).

How can I make sure the Explore link in the panel context menu expands template variables?