diff --git a/editor/src/components/shared/scoped-variables.ts b/editor/src/components/shared/scoped-variables.ts index 880a59992030..95da444f716c 100644 --- a/editor/src/components/shared/scoped-variables.ts +++ b/editor/src/components/shared/scoped-variables.ts @@ -18,6 +18,7 @@ import { jsExpressionValue, jsxConditionalExpressionWithoutUID, emptyComments, + jsExpressionIdentifier, } from '../../core/shared/element-template' import { type VariablesInScope } from '../canvas/ui-jsx-canvas' import { toComponentId } from '../../core/shared/element-path' @@ -113,15 +114,15 @@ function getMatchingElementForVariable(variable: Variable) { switch (variable.type) { case 'string': return jsxElementWithoutUID('span', jsxAttributesFromMap({}), [ - jsxTextBlock(`{${variable.name}}`), + jsExpressionIdentifier(variable.name, emptyComments, undefined), ]) case 'number': return jsxElementWithoutUID('span', jsxAttributesFromMap({}), [ - jsxTextBlock(`{${variable.name}}`), + jsExpressionIdentifier(variable.name, emptyComments, undefined), ]) case 'boolean': return jsxConditionalExpressionWithoutUID( - jsExpressionValue(variable.name, emptyComments, undefined, true), + jsExpressionIdentifier(variable.name, emptyComments, undefined), variable.name, jsExpressionValue(null, emptyComments), jsExpressionValue(null, emptyComments), diff --git a/editor/src/core/shared/element-template.ts b/editor/src/core/shared/element-template.ts index e3316434d0c3..af98ad005df4 100644 --- a/editor/src/core/shared/element-template.ts +++ b/editor/src/core/shared/element-template.ts @@ -131,14 +131,26 @@ export function jsExpressionValue( value: T, comments: ParsedComments, uid: string = UUID(), - identifier: boolean = false, ): JSExpressionValue { return { type: 'ATTRIBUTE_VALUE', value: value, comments: comments, uid: uid, - identifier: identifier, + } +} + +export function jsExpressionIdentifier( + value: T, + comments: ParsedComments, + uid: string = UUID(), +): JSExpressionValue { + return { + type: 'ATTRIBUTE_VALUE', + value: value, + comments: comments, + uid: uid, + identifier: true, } }