fix: support template expressions embedded within strings#197
Closed
iantrich wants to merge 2 commits into
Closed
Conversation
* "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>
Collaborator
|
@iantrich |
Owner
Author
|
it looks like Claude referenced the master branch for its fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #190
Previously
_evaluateTemplateassumed 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 assensor.${best_model}_p_pv_forecastorEMHASS 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