getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.
Other
179.37k stars 33.48k forks source link

Include some coverage of common tag functions for tagged template literals #1273

Open ZachSaucier opened 6 years ago

ZachSaucier commented 6 years ago

When reading though YDKJS: ES6 & Beyond; Chapter 2: Syntax about Tagged Template Literals, I thought of the case, "what if a multi-line tagged template literal is inside of a function or other containing block with indentation?" That lead me to test and see that by default it doesn't compensate for white space indentation, but YDKJS doesn't cover this case nor similar ones to it. I don't think YDKJS needs to cover all similar cases, but I think it would be a good idea to at least point to common ideas or a library of common ones such as common-tags that I came across which provides a template literal tag function called stripIndent that helps with cases like this.

Thanks for writing the book! It's thorough and very helpful for me learning new ES6 features.

getify commented 6 years ago

Good suggestion for second edition, thanks!