Last active
August 17, 2022 04:04
-
-
Save WebReflection/8f227532143e63649804 to your computer and use it in GitHub Desktop.
ES6 Template like strings in ES3 compatible syntax.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is now a module: | |
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines-- | |
var template = require('backtick-template'); | |
// just string | |
const info = 'template'; | |
`some ${info}` === template('some ${info}', {info}); | |
// passing through a transformer | |
transform `some ${info}` === | |
template(transform, 'some ${info}', {info}); | |
// using it as String method | |
String.prototype.template = template.asMethod; | |
`some ${info}` === 'some ${info}'.template({info}); | |
transform `some ${info}` === | |
'some ${info}'.template(transform, {info}); |
@aMarCruz @hooblei @JaroslavMoravec @ramtob @bcomnes
I've rewritten the original idea from scratch and covered 100% (let's say it was an excuse to test coveralls but ... hey ...)
https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
Best Regards
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Has anyone turned this into a module instead of a prototype extend?