Tagged Template Literals

preview_player
Показать описание
Template literal strings are great for embedding (interpolating) variables and expressions inside JavaScript strings.
They also include a feature called tagged template literals that let you create a function which will give you granular control over all the strings and expressions inside the template string.

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

Rewatching this video after 7 months. I love the pace.

bruhmoment
Автор

i don't know why you and dcode has far less subscribers although you both are among the best ! Thank you for the effort you put into this. keep up the amazing work!

theartist
Автор

This is a great way to make html templates using vanilla js. It's what I've been using and it works 👍

Tips:

1. Replace null valued variables to empty strings. This will allows you to do conditional rendering similar to react using the && operator.

2. Join array variables automatically so you can render looping template (cards, table rows, etc.) cleanly.

3. Use "html" as your tagged template literal function name so vscode extensions will pick it up and format them as html.

dputra
Автор

Clearest tagged template video ever, thanks Steve, u are the best.

golcuk
Автор

Now (3 years after the video was posted) there's a pretty neat feature `String.raw`. It helps simplify the function at 10:25 to a one-liner:
```
const f = (strings, ...values) => String.raw({ raw: strings }, ...values.map(i => i.toUpperCase()))
```

richardschloss
Автор

I love your content. Your content has improved me a lot♥️♥️

techlover
Автор

Hey Steve. You make some damn fine content, really really excellent.

phanCAbe
Автор

trying to understand this on mdn was a nightmare, thanks Professor Steve!

moooo
Автор

Had NO clue about this one. Very helpful video, thanks!

rebelmachine
Автор

Thanks for putting the effort to make this video.
This is the first time I know about tagged template literals.
Also, you sound a bit like a calmer RDJ 😁

ProjectXH
Автор

Hey Steve! Thank you. That was very very understandable

ariyaman
Автор

Thank you for this tutorial. It helped me.

howiewang
Автор

Can you give more examples or provide a link or something inorder to have a more clear idea of how to implement this concept its sure interesting though

rohanbaikar
Автор

Thank you again. I have a question about the template literal..
When i am using template literal to print a object it is showing [object Object]..but when i am using the traditional way, it is showing the value of the object.
Please explain the reason of this behaviour.

techlover
Автор

Thanks, steve how do i get the coordinates appear in real time(updated with little change in position)

emmanuelyawson
Автор

Hey steve great contents. So here comes the weird suggestion. Have you ever thought about doing a voice over work or reading an audio book? I just think you should at least look in to it. You have a great voice. Any way i love your javascript lessons thank you for making videos.

MrKelbessa
Автор

cool, looks like a boon for generated JS, generated from other Languages
:-)

theoligarchist
Автор

According to your Time there I think 4:00 am right now, brother you are making video at that time

devkushwaha
Автор

im back again to ask look at this code (i couldnt understand how the keys and value of the objects are passed as parametres on the function)

this is the code:

const user = {
id: 101010,
name: "Derek",
};


function replace(key, value) {
if (typeof value == 'number') {
return undefined;
}
if (key == 'email') {
return ' remover for privacy';
}
return value;
};

//when i console this how does the keys and values from user object are used as parametres in replace
console.log(JSON.stringify(user, replace));

silentstorm