Skip to content

Using several templates in a string may cause errors #166

@ildar170975

Description

@ildar170975

Checklist:

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

Release with the issue:
1.3.7-beta.1

Last working release (if known):

Browser and Operating System:
Chrome 134.0.6998.36
Win10x64

Description of problem:

Consider this example:

type: vertical-stack
cards:
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: ${VAR}
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: '${VAR}'
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: "${VAR}"
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: >-
        ${VAR}

All cards only differ in a way of using a template:
-- no quotes
-- in single quotes
-- in double quotes
-- with >- multiline-yaml syntax

Results are same correct:
Image

Now let's test with several templates in a string:

type: vertical-stack
cards:
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: ${VAR} ${VAR}
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: '${VAR} ${VAR}'
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: "${VAR} ${VAR}"
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: >-
        ${VAR} ${VAR}

In all cases it gives an error:
Image

Using more quotes gives a result - but values are embraced by quotes:

type: vertical-stack
cards:
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: '''${VAR} ${VAR}'''
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: "'${VAR} ${VAR}'"
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: '"${VAR} ${VAR}"'
  - type: custom:config-template-card
    entities:
      - sun.sun
    variables:
      VAR: states['sun.sun'].state
    card:
      type: markdown
      content: >-
        '${VAR} ${VAR}'

Image

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


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