INNER CODE UNIT · TypeScript

nunjucksRender

org-formation/org-formation-cli · src/yaml-cfn/index.ts:145

export const nunjucksRender = (input: string, filename: string, templatingContext: any): string => {
  const rendered = env.renderString(input, templatingContext);
  if (NunjucksDebugSettings.debug) {
    debugWriteNunjucksTemplate(filename, input, templatingContext, rendered);
  }
  return rendered;
};


export const debugWriteNunjucksTemplate = (filename: string, input: string, templatingContext: any, output: string): void => {
  try {
    const outputPath = path.resolve(NunjucksDebugSettings.path, path.basename(filename));
    mkdirSync(outputPath, { recursive: true });
    writeFileSync(path.join(outputPath, 'input.txt'), input);
    writeFileSync(path.join(outputPath, 'output.txt'), output);
    writeFileSync(path.join(outputPath, 'templating-context.json'), JSON.stringify(templatingContext, undefined, 2));

  } catch (err) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…