Fixing issue with HBS insert, not including curlies as required. Also fixing an issue with value not always being correctly updated.

This commit is contained in:
mike12345567 2022-02-15 11:19:59 +00:00
parent 9c99aefef3
commit 9cf3d97b4d
2 changed files with 7 additions and 3 deletions

View File

@ -51,8 +51,9 @@
}) })
$: codeMirrorHints = bindings?.map(x => `$("${x.readableBinding}")`) $: codeMirrorHints = bindings?.map(x => `$("${x.readableBinding}")`)
const updateValue = value => { const updateValue = val => {
valid = isValid(readableToRuntimeBinding(bindings, value)) valid = isValid(readableToRuntimeBinding(bindings, val))
value = val
if (valid) { if (valid) {
dispatch("change", value) dispatch("change", value)
} }

View File

@ -1,7 +1,10 @@
export function addHBSBinding(value, caretPos, binding) { export function addHBSBinding(value, caretPos, binding) {
binding = typeof binding === "string" ? binding : binding.path binding = typeof binding === "string" ? binding : binding.path
value = value == null ? "" : value 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} }}` binding = `{{ ${binding} }}`
} }
if (caretPos.start) { if (caretPos.start) {