Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-5737

JS Support for symbols/*/templates.yaml Files

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 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 Unassigned
            Reporter:
            preston.vasquez@mongodb.com Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: