Skip to content

fix: support template expressions embedded within strings#197

Closed
iantrich wants to merge 2 commits into
betafrom
claude/issue-190-20260515-2208
Closed

fix: support template expressions embedded within strings#197
iantrich wants to merge 2 commits into
betafrom
claude/issue-190-20260515-2208

Conversation

@iantrich

Copy link
Copy Markdown
Owner

Fixes #190

Previously _evaluateTemplate assumed the entire string was a single template expression like ${expr}, and would strip the surrounding ${...} to eval the inner JS. This broke strings with embedded templates such as sensor.${best_model}_p_pv_forecast or EMHASS Forecasts (Model ${best_model}), producing garbled JavaScript and SyntaxErrors.

Now the function detects whether the value is a pure single-expression template (evaluates directly to preserve return type) or a string with embedded template expressions (evaluates as a JS template literal so the interpolated string is returned correctly).

Generated with Claude Code

iantrich and others added 2 commits May 15, 2026 17:07
* "Claude PR Assistant workflow"

* "Claude Code Review workflow"
Previously _evaluateTemplate assumed the entire string was a single
template expression like ${expr}, and would strip the surrounding ${...}
to eval the inner JS. This broke strings with embedded templates such as
sensor.${best_model}_p_pv_forecast or "Title ${var} text", producing
garbled JavaScript and SyntaxErrors.

Now the function detects whether the value is a pure single-expression
template (evaluates directly to preserve return type) or a string with
embedded template expressions (evaluates as a JS template literal so
the interpolated string is returned correctly).

Fixes #190

Co-authored-by: Ian Richardson <iantrich@users.noreply.github.com>
@iantrich iantrich changed the base branch from master to beta May 15, 2026 22:14
@iantrich iantrich requested a review from ildar170975 May 15, 2026 22:14
@iantrich iantrich closed this May 15, 2026
@iantrich iantrich reopened this May 15, 2026
@ildar170975

Copy link
Copy Markdown
Collaborator

@iantrich
Will review in a few days when be back to PC

@iantrich

Copy link
Copy Markdown
Owner Author

it looks like Claude referenced the master branch for its fix

@iantrich iantrich closed this May 16, 2026
@iantrich iantrich deleted the claude/issue-190-20260515-2208 branch May 16, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Card not showing after update to beta 2.0.0-b1

2 participants