JS Support for symbols/*/templates.yaml Files

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • None
    • 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`);

            Assignee:
            Unassigned
            Reporter:
            Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: