admin管理员组文章数量:1322838
For our application we need to use new feature template string
.
var verLongKey= `834r845784576485
y84ery5845y485yu843
483y53485684576845
jhu87843647356756745==457485,mh
ererthe8t0998785==ery8`;
But old browsers(like android default browsers) don't support template string.
How can I get polyfill for this feature?
Tried babel
. We got this polyfill working for all features but template string
.
Currently using modernizr
to detect support and show alert to use other browser.
This approach is annoying for users. How can i get some polyfill to make this work on the non supporting browsers?
What made us this template strings
.
The problem is i can't use these tools(trceur
,babel
) as this file is generated on the production from puppet
. There is no way we will run these transpilers there. want to add some polyfill on the browser side. the key contains some \n
characters in it need to preserve those. I want some polyfill so, i can include before the configs js file.
For our application we need to use new feature template string
.
var verLongKey= `834r845784576485
y84ery5845y485yu843
483y53485684576845
jhu87843647356756745==457485,mh
ererthe8t0998785==ery8`;
But old browsers(like android default browsers) don't support template string.
How can I get polyfill for this feature?
Tried babel
. We got this polyfill working for all features but template string
.
Currently using modernizr
to detect support and show alert to use other browser.
This approach is annoying for users. How can i get some polyfill to make this work on the non supporting browsers?
What made us this template strings
.
The problem is i can't use these tools(trceur
,babel
) as this file is generated on the production from puppet
. There is no way we will run these transpilers there. want to add some polyfill on the browser side. the key contains some \n
characters in it need to preserve those. I want some polyfill so, i can include before the configs js file.
- 7 What makes you "need" template strings? You can do everything pretty easily without them too, you know... – Madara's Ghost Commented Feb 29, 2016 at 8:25
- @MadaraUchiha agree, same result can be achieved with ES5: stackoverflow./a/35695834/1092711 – Pavlo Commented Feb 29, 2016 at 9:28
- 1 @MadaraUchiha Having to backport a lot of code which uses template strings extensively is not fun, considering that the use of templates allows dynamically templated code embedded in strings (Javascript, SQL, etc.) to actually be readable and maintainable. – Michael Commented Dec 3, 2016 at 18:06
- @Michael But he isn't backporting, he's looking for a polyfill, meaning he currently isn't using it, but wants to. Also, Using template strings for SQL is a really bad idea – Madara's Ghost Commented Dec 3, 2016 at 19:50
1 Answer
Reset to default 9There are 3 main ES6 polyfills that can give you template string support but none of them have full support as you can see at kangax's ECMAScript support table.
Traceur - This is Google's ECMAScript polyfill that support some ECMAScript 6 and ECMAScript next features, it have 4/5 support for template strings, there is no toString conversion.
Babel - Another ECMAScript polyfill, have more support in general but also have only 4/5 support for template strings, also no toString conversion.
es6-shim - I'm not sure if it's even developed anymore, but it doesn't have template strings anyway.
But you might want to think twice before using template string, it just a syntactic sugar for string with + to add variables and \ to have multi lines.
本文标签: javascriptHTML5ES6 template string polyfillStack Overflow
版权声明:本文标题:javascript - HTML5, ES6 template string polyfill - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740977711a2318025.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论