-
Type: Task
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Export to Language, Tech debt
-
None
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`);