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

1.3k views Asked by At

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.

2

There are 2 answers

0
stevecross On BEST ANSWER

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.

0
Keith On

If you want to use new JS features in old browsers/JS engines your best bet is a transpiler like Babel.

This takes modern JS and recompiles it down to older versions, so you can target ES3 with ES2017 features.