Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 17:31:26 +00:00
co-authored by renee-png
parent 07272374d4
commit 6bbca318f6
+12 -3
View File
@@ -198,6 +198,7 @@ export function applyVariables(
homeowner?: HomeownerLite | null;
firmName?: string;
customValues?: Record<string, string>;
clientCustomValues?: Record<string, string>;
fieldValues?: Record<string, string>;
},
): string {
@@ -215,11 +216,12 @@ export function applyVariables(
let out = body;
// System variables: {{name}} or {{name|modifier}}
// Client custom-field variables: {{client.custom.key}} or {{client.custom.key|modifier}}
// Must run BEFORE the generic {{custom.key}} pattern so the prefix isn't swallowed.
out = replaceWithModifier(
out,
/\{\{\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\|\s*([a-zA-Z]+)\s*)?\}\}/g,
(name) => systemValues[name],
/\{\{\s*client\.custom\.([a-zA-Z0-9_]+)\s*(\|\s*([a-zA-Z]+)\s*)?\}\}/g,
(name) => ctx.clientCustomValues?.[name],
);
// Custom case-field variables: {{custom.key}} or {{custom.key|modifier}}
@@ -236,6 +238,13 @@ export function applyVariables(
(name) => ctx.fieldValues?.[name],
);
// System variables: {{name}} or {{name|modifier}} — run LAST so dotted vars above win.
out = replaceWithModifier(
out,
/\{\{\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\|\s*([a-zA-Z]+)\s*)?\}\}/g,
(name) => systemValues[name],
);
return out;
}