Skip to content

Dynamic content of a Grid card stopped working #191

Description

@ildar170975

Checklist:

  • I updated to the latest version available
  • I cleared the cache of my browser

Release with the issue:
2.0.0-b1

Last working release (if known):
1.3.6
1.3.7-beta.1

Browser and Operating System:
Chrome 145.0.7632.160
Win10x64

Description of problem:

This code used to work before 2.0.0-b1:

type: custom:config-template-card
variables:
  LIGHTS: |-
    Object.keys(states).filter(
      k => k.startsWith('light')
    )
entities: ${LIGHTS}
card:
  type: grid
  square: false
  columns: 3
  title: CTC
  cards: |-
    ${
      let cards = [];
      LIGHTS.map(entity =>
        cards = cards.concat(
          {
            'type': 'tile',
            'entity': entity,
            'tap_action': {'action': 'toggle'}
          }
        )
      );
      cards;
    }
Image Image

Now it shows nothing, only errors in a console.

Javascript errors shown in the web inspector (if applicable):

Uncaught (in promise) SyntaxError: Unexpected identifier 'cards'
    at new Function (<anonymous>)
    at h (config-template-card.js?hacstag=1721775432001:39:4725)
    at $t._evaluateTemplate (config-template-card.js?hacstag=1721775432001:39:5255)
    at config-template-card.js?hacstag=1721775432001:39:4260
    at Array.forEach (<anonymous>)
    at $t._evaluateConfig (config-template-card.js?hacstag=1721775432001:39:4075)
    at $t.render (config-template-card.js?hacstag=1721775432001:39:2733)
    at $t.update (config-template-card.js?hacstag=1721775432001:23:236)
    at $t.performUpdate (config-template-card.js?hacstag=1721775432001:12:4877)
    at $t.scheduleUpdate (config-template-card.js?hacstag=1721775432001:12:4397)

Additional information:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions