From 16aee9dc7177dc3bae6125cd597e0e651e9ed72b Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 29 Mar 2020 21:21:39 -0400 Subject: working version of nested templates both inside and outside of text boxes. --- src/client/util/DropConverter.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/client/util') diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts index d201934ea..28d88d867 100644 --- a/src/client/util/DropConverter.ts +++ b/src/client/util/DropConverter.ts @@ -15,14 +15,22 @@ import { ImageField } from "../../new_fields/URLField"; // after it has been converted to export function makeTemplate(doc: Doc, first: boolean = true, rename: Opt = undefined): boolean { const layoutDoc = doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc; - if (layoutDoc.layout instanceof Doc) return true; + if (layoutDoc.layout instanceof Doc) { // its already a template + return true; + } const layout = StrCast(layoutDoc.layout).match(/fieldKey={'[^']*'}/)![0]; const fieldKey = layout.replace("fieldKey={'", "").replace(/'}$/, ""); const docs = DocListCast(layoutDoc[fieldKey]); let any = false; docs.forEach(d => { if (!StrCast(d.title).startsWith("-")) { - any = Doc.MakeMetadataFieldTemplate(d, Doc.GetProto(layoutDoc)) || any; + const params = StrCast(d.title).match(/\(([a-zA-Z0-9_-]*)\)/)?.[1].replace("()", ""); + if (params) { + any = makeTemplate(d, false) || any; + d.PARAMS = params; + } else { + any = Doc.MakeMetadataFieldTemplate(d, Doc.GetProto(layoutDoc)) || any; + } } else if (d.type === DocumentType.COL || d.data instanceof RichTextField) { any = makeTemplate(d, false) || any; } -- cgit v1.2.3-70-g09d2