Tagged Template Literals

preview_player
Показать описание
What are Template literals and how do you write a tagged template function.

Рекомендации по теме
Комментарии
Автор

Really nice feature. Thanks BTW for the real world practical hands-on + rest of the examples you've mentioned in the video.

kasir-barati
Автор

Thank you Kent for these wonderful livestreaming!

escapiststupor
Автор

Thanks for going over this, I'm still having trouble understanding why you'd want to go this route though. At least in the case of the translation example, I'd probably prefer doing something like:
(user, language=language)=>{ //lang can be passed in or defaulted to browser/state or something else
const {hello, yourBirthdayIs} = getTranslations(language);
const {name, birthday} = user;
return `<div>${hello}${name},
}

But maybe thats just this example, or maybe it just makes me feel dirty using string search to filter out my replacements.

sikz
Автор

Reduce the interpolations always (since its length is always 1 fewer than the literals)
interpolations.reduce((acc, current, i) => acc + current + literals[i + 1], literals[0])
More succinct this way.

gosnooky
Автор

What syntax theme are you using? Edit: found it already, its Nightowl.
Nice video btw

julianklumpers