thomasloven / lovelace-card-mod

🔹 Add CSS styles to (almost) any lovelace card
MIT License
1.08k stars 168 forks source link

SyntaxError: The string did not match the expected pattern #199

Closed Mariusthvdb closed 5 months ago

Mariusthvdb commented 2 years ago

My Home Assistant version: 2022.6.0.dev20220430

My lovelace configuration method (GUI or yaml): Yaml

What I am doing:

card-mod-theming an icon in a view/tab

What I expected to happen:

icon change

What happened instead:

no icon change because of space in the view title

Minimal steps to reproduce:

# The least amount of code possible to reproduce my error
    card-mod-root-yaml: |
      paper-tab[aria-label='Weer & Klimaat'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: {{states('sensor.weather_icon')}};
          color: {{states('sensor.temperature_color_name')}};
        }
# End of code

doesn't matter if I simply add mdi:car; its not about the icon template, its really about the view title (aria-label), because:

      paper-tab[aria-label='Alarm'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: {{states('sensor.alarm_panel_icon')}};
          color: {{states('sensor.alarm_panel_icon_color')}};
        }

works perfectly.

Error messages from the browser console:

Schermafbeelding 2022-04-30 om 10 42 03

I have also tested it under:

      .: |
        /* Set the color of individual tabs. */
        paper-tab[aria-label='Weer & Klimaat'] {
          color: {{states('sensor.temperature_color_name')}};
        }

but in that section, only the colors change, and not the icons. But it does accept the white space in the label without problem.

Finally, I also tried the space indicator &nbsp to have it evaluate

 paper-tab[aria-label='Weer&nbsp&&nbspKlimaat']

but that took the instance down ....

only way to make it happen is to tie the words with a -

      paper-tab[aria-label='Settings-motion'] ha-icon$: |
        ha-svg-icon {
          --card-mod-icon: mdi:car;
          color: {{'red' if is_state('binary_sensor.motion_sensors_all','on')}};
        }

Please have a look if this can be fixed

By putting an X in the boxes ([]) below, I indicate that I:

Mariusthvdb commented 5 months ago

closing as I have changed card-mod-themes and modern card-mod no longer logs these syntax errors