[COMPASS-5737] JS Support for symbols/*/templates.yaml Files Created: 13/Apr/22  Updated: 04/Dec/23

Status: Needs Triage
Project: Compass
Component/s: Export to Language, Tech debt
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Preston Vasquez Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: COMPASS-7501

 Description   

Request

Add an optional symbols/*/Templates.js file that exports and object and can be merged into the contents of the yaml template files. 

Motivation

This will allow us to use linters and have syntax-highlighting when interacting with the language symbol templates.

Proposal

We could add a new file symbols/*/Templates.js that looks something like this:

module.exports = {
  AndSyntaxTemplate: (args) => args.join(' && ')
};

And forgo writing anything to the symbols/*/templates.yaml file:

# yaml file
AndSyntaxTemplate: &AndSyntaxTemplate null

Then when we run the loadSymbolTable function in compile-symbol-table.js we could merge the hash from the js template doing something like this:

const yamlContents = yaml.load(contents);
yamlContents.Templates = {...yamlContents.Templates, ...jsTemplates.get(outputLang)};
fs.writeFileSync(outputFile, `module.exports=${JSON.stringify(yamlContents)};\n`);


Generated at Wed Feb 07 22:40:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.