Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-6745

Issue with moodle ci mustache linter failing on {{#js}}

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Low Low
    • Integration
    • None

      https://github.com/moodlehq/moodle-local_ci/blob/master/mustache_lint/mustache_lint.php#L253

      This is the part of the github action logs showing the error:
       

       RUN Mustache Lint on tool_dataflows    2105/home/runner/work/moodle-tool_dataflows/moodle-tool_dataflows/moodle/admin/tool/dataflows/templates/available-fields.mustache - WARNING: ESLint error []: Parsing error: Unexpected token expression ( ), Line: 3 Column: 13    2106PHP Notice: Undefined property: stdClass::$source in /home/runner/work/moodle-tool_dataflows/moodle-tool_dataflows/m-ci/vendor/moodlehq/moodle-local_ci/mustache_lint/mustache_lint.php on line 252   

      The logs (likely won't work after a while)
      https://github.com/catalyst/moodle-tool_dataflows/runs/7646277609?check_suite_focus=true#step:4:2129
       
      The code in question is in flux, but I think it isn't happy parsing certain tokens of js inside a mustache template:

      {{#js}}
          require(['core/toast', 'core/str'], function(addToast, getString) {
              let expression = document.querySelectorAll('.leaf-expression');
              for (let i = 0; i < expression.length; i++) {
                  expression[i].addEventListener('click', e => {
                      let exp = e.target.closest('.leaf');
                      let text = exp.getElementsByTagName('textarea')[0]
                      text.select();
                      document.execCommand("copy");
                      addToast.add(getString.get_string('successfullycopiedtoclipboard', 'tool_dataflows', text.value), {
                          type: 'info',
                          autohide: true,
                          closeButton: true,
                      });
                  });
              }
          });
      {{/js}} 

      Worth noting that the mustache template works fine both in real use and in the templatelibrary so even if there is a code standards problem the template is clearly still correct and should parse.

            dobedobedoh Andrew Lyons
            brendanheywood Brendan Heywood
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.