MCPcopy Create free account
hub / github.com/continuedev/continue / renderTemplatedString

Function renderTemplatedString

core/util/handlebars/renderTemplatedString.ts:8–35  ·  view source on GitHub ↗
(
  handlebars: HandlebarsType,
  template: string,
  inputData: Record<string, string>,
  availableHelpers: Array<[string, Handlebars.HelperDelegate]>,
  readFile: (filepath: string) => Promise<string>,
  getUriFromPath: (path: string) => Promise<string | undefined>,
)

Source from the content-addressed store, hash-verified

6} from "./handlebarUtils";
7
8export async function renderTemplatedString(
9 handlebars: HandlebarsType,
10 template: string,
11 inputData: Record<string, string>,
12 availableHelpers: Array<[string, Handlebars.HelperDelegate]>,
13 readFile: (filepath: string) => Promise<string>,
14 getUriFromPath: (path: string) => Promise<string | undefined>,
15): Promise<string> {
16 const helperPromises = availableHelpers
17 ? registerHelpers(handlebars, availableHelpers)
18 : {};
19
20 const ctxProviderNames = availableHelpers?.map((h) => h[0]) ?? [];
21
22 const { withLetterKeys, templateData } = await prepareTemplatedFilepaths(
23 handlebars,
24 template,
25 inputData,
26 ctxProviderNames,
27 readFile,
28 getUriFromPath,
29 );
30
31 const templateFn = handlebars.compile(withLetterKeys);
32 const renderedString = templateFn(templateData);
33
34 return resolveHelperPromises(renderedString, helperPromises);
35}

Callers 2

llmFromDescriptionFunction · 0.90
getRenderedV1PromptFunction · 0.90

Calls 3

registerHelpersFunction · 0.90
resolveHelperPromisesFunction · 0.90

Tested by

no test coverage detected