Card Visibility based on template output

I have the script listed below which shows me if any device goes offline, but I cannot figure out how to make it visible only when there is output.
I figure to achieve this I will need to either make the content section switch an input boolean, which will give me a simple input for visibility or figure out how to put a template in the visibility section, or at least accept a variable from the content section.

Any ideas?

type: markdown
content: |-
  ### Offline:
  {%- set exclude = [
    'f7b3ace4cca80ff364d43a63855fa4b4',
    '2778683f71793a0a90ae49a8e50b97e7',
    'a1ddf72f902ebfd0e150f006ba912fb3',
    'e5983e62a5daec9350472fd0236e4190',
    'a5377fce2dcc76210014135a9d7e7b31',
    'bb5e656f1710092ca463b5838b4f6360',
    '7bb5a5f861c796a8bc192273eed2a37e',
    'bb1ec74dc0a01c3566d7238583d6bd8b',
    '204e8bcdb3252eaaa5629f4e2f0c3291',
    'd6122144dda9c1604e9016d64e4d981c'
  ] -%}
  {%- set ns = namespace(seen=[]) -%}
  {%- for entity in states if entity.state == 'unavailable' -%}
    {%- set dev_id = device_id(entity.entity_id) -%}
    {%- if dev_id not in exclude -%}
      {%- set dev_name = device_attr(dev_id, 'name') -%}
      {%- if dev_name not in ns.seen %}
  {{ dev_name }} {{ dev_id }}
        {%- set ns.seen = ns.seen + [dev_name] %}
      {%- endif %}
    {%- endif %}
  {%- endfor %}
grid_options:
  columns: 9
  rows: auto
tap_action:
  action: navigate
  navigation_path: /config