Skip to content

[BUG] Inconsistent handling of template variables in button text expressions #3772

@arikorn

Description

@arikorn

Make sure you're on the latest stable or beta build

  • I have tested this on the latest stable or beta release

Is this a bug in companion itself or a module?

  • I believe this to be a bug in companion and not a specific module

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Buttons using text expressions interpret template variables differently depending on how they're presented. Consider two variables:

$(custom:myVar1) = 123
$(custom:myVar2) = `$(custom:myVar1)` // (probably need to set this with an action)

With these you can set button text two ways:

  1. Text expression: `$(custom:myVar1)`. Button shows uninterpreted text: "$(custom:myVar1)"
  2. Text expression: $(custom:myVar2). Button shows "123", even though the Variables tab confirms that the value is $(custom:myVar1)

This issue records the "conclusion" of PR #3768, which was presented poorly (by me) and whose proposed solution was found wanting (even by me).

Since the problem is inconsistency, one can solve it either by making case 1 behave like case 2 or by making case 2 behave like case 1. My suggestion had been to resolve custom variables in template literals (at least in button text) in the same way the ${} is resolved, i.e. `text $(module:variable)` is treated the same as `text ${$(module:variable)}` currently is treated. This met with opposition, so another solution to the underlying inconsistency is needed.

Steps To Reproduce

See description, above.

Expected Behavior

The two cases should result in the same text showing up on the button.

Environment (please complete the following information)

- OS: Windows 10
- Browser: Chrome
- Companion Version: latest beta, latest stable.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions