Search code examples
javascriptmako

How to solve string templates are not supported by current javascript version


I try to use the answer from my previous question

Enable datatables with custom layout

But I get an error message in Pycharm:

"String templates are not supported by current javascript version"

Do you know what I can do about it? If I replace with actual quotes then I get the error that Mako tries to intepret the this.index variable as a Mako variable.


Solution

  • It seems that you are using a JavaScript version prior to ECMAScript 2015 and thus string templates are not supported. You have to build the string on your own:

    table.columns().every(function() {
        var that = this;
        $('#example thead input:nth(' + this.index() + ')').on('keyup change', function() {
            if (that.search() !== this.value) {
                that
                    .search(this.value)
                    .draw();
            }
        });
    });
    

    As Keith suggests in his answer you should use a transpiler like Babel. This gives you a lot of new functionalities and will make your life easier.