Template Literals



Template Literals

  • should enable embedding languages
  • but escape sequences are a problem
function latex(strs) {
  // ...

let doc = latex`

Breve over the h goes \u{h}ere 

Remove EscapeSequence restriction

for tagged template literals

  • Illegal EscapeSequences no longer a syntax errorĀ 
  • Set cooked values with illegal escape sequences to undefined
  • Programmers still have access to raw
  • Untagged illegal escapes are still a syntax error
function tag(strs) {
  strs[0] === undefined
  strs.raw[0] === "\\unicode ";

  strs[1] === " U";
  strs.raw[1] === " \\u{55}";
tag`\unicode ${"and"} \u{55}`

// syntax error
let untagged = `\unicode and \u{55}` 

Grammar Details

One more thing...

<!doctype html>
        "use </script"
       let s = html`</script>`

Template Literal Proposal May

By disnet

Template Literal Proposal May

  • 850
Loading comments...

More from disnet