This course has been updated! We now recommend you take the Angular 9 Fundamentals course.
Transcript from the "Templating" Lesson
>> Scott Moss: So what we're gonna do now is we're gonna automate these things. So what I mean by automate, I mean we write the same stuff over, and over, and over again. Like admin, blog, blog post, common home. They all have the same, they definitely have the same files.
[00:00:40] They also create a module. So there were some common things there. So we can just automate this using gulp. This is a reason why I wanted to use gulp with webpack because if we use webpack we're won't be able to automate this. Webpack, its job is not to do this type of thing that we're about to do, its job is to build files.
[00:00:55] It's not gonna automate a template system for you, whereas gulp will cuz it's just a streaming system. So we're gonna use gulp for that. Now before we do that, because this one's actually kind of complicated that's why I saved it for the last. I wasn't even too sure if I was gonna do it, but I think it's important for everybody to see it.
[00:01:33] So we have a function called, let's just say make template. Just imagine there's a function called make template somewhere, okay. And what we do is we'll have like an object.
>> Scott Moss: And it will have some properties on it. Name, hey, all right. And then what we'll do is we'll have a string.
[00:02:18] And it'll do something like this. So it will take in the string, oops. I guess I should give these names, right?
>> Scott Moss: It'll take in the string, and then the object. And then what it will do is return the compiled result.
>> Speaker 2: So does Angular have a templating engine?
>> Scott Moss: Yes.
>> Speaker 2: When you do.
>> Scott Moss: Yep.
>> Speaker 2: Okay.
>> Scott Moss: That's exactly right. So we're gonna use a very micro one, but a very powerful. It's built into Lodash and it's the exact same thing that's in Underscore. So if you ever used Underscore templates or Lodash templates, it's exact same thing, that's what we're about to use.
[00:02:59] It actually kinda looks like, yeah, it's Underscore and Lodash. If you've used it's the same thing. So that's the methodology behind templating. It's gonna be something like that. Sometimes you'll do something like this. You'll do this and this will return a function compiler. And then you'll say compiler.
>> Scott Moss: And then you'll pass in the options at some later time which will return the value. So, but either way, it's the same concept.
>> Scott Moss: But yeah, Angular does the same thing. In fact Angular has a
>> Scott Moss: compile.
>> Speaker 2: Yeah, I've seen that.
>> Scott Moss: Thing that does that with interpolation.
[00:03:45] Cool, so that's the basics of templating. And I just want to give you that context, because most of the stuff you're gonna see in the next step is already there. But I want you to understand what's going on. So to help you out.