After studying this Es6 tag template example:
var yo = func`${x} + ${y}\n= ${x + y}`;
one@public-node ~/es6 $ 6to5 tag.js
"use strict";
var _taggedTemplateLiteral = function (strings, raw) {
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
};
var yo = func(_taggedTemplateLiteral(["", " + ", "\n= ", ""], ["", " + ", "\\n= ", ""]), x, y, x + y);
I see what is returned is var yo = func(strings, raw, x, y, x + y);
I understand the basics about the string literals and the x
y
values being inserted. What I don't understand is...when is strings used versus when is raw used? Since the function has both arrays and the user doesn't have control to tell the function when to use raw and when to use cooked(strings).