Hacker News new | past | comments | ask | show | jobs | submit login

For anyone unfamiliar with the syntax used to achieve this, it's called Tagged Template Literals [0] and it's part of ES2015. You have a function that receives the static strings and interpolations and can return anything you want.

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...




One of my favorite uses of tagged template literals is for HTML-encoding variables into an HTML string with (my module) https://www.npmjs.com/package/auto-html.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: