From ce28aff3f9e08973dc07bfc44a6ea721fe63d40c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 15 Feb 2022 11:19:59 +0000 Subject: [PATCH] Fixing issue with HBS insert, not including curlies as required. Also fixing an issue with value not always being correctly updated. --- .../src/components/common/bindings/BindingPanel.svelte | 5 +++-- packages/builder/src/components/common/bindings/utils.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index ee0169f9e7..08578fff33 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -51,8 +51,9 @@ }) $: codeMirrorHints = bindings?.map(x => `$("${x.readableBinding}")`) - const updateValue = value => { - valid = isValid(readableToRuntimeBinding(bindings, value)) + const updateValue = val => { + valid = isValid(readableToRuntimeBinding(bindings, val)) + value = val if (valid) { dispatch("change", value) } diff --git a/packages/builder/src/components/common/bindings/utils.js b/packages/builder/src/components/common/bindings/utils.js index 28845fe12b..42a3f11677 100644 --- a/packages/builder/src/components/common/bindings/utils.js +++ b/packages/builder/src/components/common/bindings/utils.js @@ -1,7 +1,10 @@ export function addHBSBinding(value, caretPos, binding) { binding = typeof binding === "string" ? binding : binding.path value = value == null ? "" : value - if (!value.includes("{{") && !value.includes("}}")) { + + const left = caretPos?.start ? value.substring(0, caretPos.start) : "" + const right = caretPos?.end ? value.substring(caretPos.end) : "" + if (!left.includes("{{") || !right.includes("}}")) { binding = `{{ ${binding} }}` } if (caretPos.start) {