Home » Javascript » Polyfill for javascript template strings

Polyfill for javascript template strings

Posted by: admin August 19, 2018 Leave a comment

Questions:

Are there any polyfills for javascript template strings that use a backtick? I’m referring to code that looks like this:

var textTemplate = `
   <h1>My Template String</h1>
   <p>Some more stuf here...</p>
`;

I do not wish to use a transpiler such as babel or any other tools that require a build step. Additionally, javascript template engines that place the template inside of a separate script tag are not ideal for me either.

I’d really just like to be able to use template strings alongside otherwise standard ES5 code in the same file. Is this possible?

EDIT: I specifically need template strings to work in IE11. I realize they already do in most other browsers. I’m also now aware that polyfill isn’t the correct terminology for what I am wanting.

Answers: