This course contains good reference material, but does not reflect our current quality standards.

Check out a free preview of the full Organizing JavaScript Functionality course:
The "Templating Questions" Lesson is part of the full, Organizing JavaScript Functionality course featured in this preview video. Here's what you'd learn in this lesson:

Kyle spends a few minutes answering some questions about the templating engine. He also talks about using other frameworks like React and Ember.

Get Unlimited Access Now

Transcript from the "Templating Questions" Lesson

>> Student: Quick question.
>> Kyle Simpson: Yes.
>> Student: Is there a way that I can tell the watch to ignore certain file name?
>> Kyle Simpson: Yeah. If you look at the documentation for the watch module, there's all kinds of special configuration filters and stuff.
>> Student: Read special file.
>> Kyle Simpson: Yeah.
>> Kyle Simpson: I don't see any other questions a couple people just mentioning that they do or don't like certain things about the templates, but all right.

[00:00:34] So the next thing [COUGH] that we wanna talk about that's how I'm reusing my template engine. So I'm doing my rendering exactly the same in both places. And actually let me just prove that to you. So here I show you how I'm doing it on the server. I'm calling that View.getPageHTML.

[00:00:49] If I open up web > JS > View.js, now let's look at pages. Pages as my page controller, if I look at that this is the thing that's running in the browser. And whenever something is asked for like if we try to load up a, so this one is my click handler for links that I basically wanna ajaxify.

[00:01:13] I'm listening for any links that aren't marked as being a ignorable. And if I recognize the href of that tag as being an internal page that I have a template for, then I simply call this gotoPage function which not terribly surprisingly is going to call view.getPageContentHTML, okay? So it's the exact same path and this code ends up running exactly identically between server and browser.

>> Kyle Simpson: Okay, let's see, would you say react would be good here. React is awesome, but I think it's a much bigger hammer than most people need. That's what I'll say. Okay.
>> Kyle Simpson: By the way, on that topic of like what are other potential options or whatever. I don't know how many of you here in person or online or listening to the video have heard of Ember.

[00:02:21] But it's one of the big three, if you also there's ember there's angular there's reacts. It's one of the big three at the moment in that whole like framework rendering the sort of thing. Now I'm not using Ember. I'm not a Ember user. I know quite a few people who are.

[00:02:41] They're really smart people. So I am not in any way shape or form suggesting that Ember's bad because I don't use it. It's way overkill for what I need. And that's why I don't use it. I always start with the simple stuff first rather than pull in a huge framework that is mostly what I don't need.

[00:02:58] But there's one particular point I wanna bring up about Ember, and this is a praise of them more than, it's not a criticism at all. Just recently Ember released a whole series of new stuff. And if you have kept up at all or read anything about it, they released a new thing called Glimmer, which is a new way of doing their renderings and stuff like that.

[00:03:20] Where they're looking at their template partials they call them different things but if they're essentially template partials and figuring out the minimum template partial that needs to be rendered and then redoing it. That's really, really cool stuff and that's exactly why I built grips five years ago cuz I was doing that exact same thing.

[00:03:39] So I'm really excited to see a really smart set of people come along with a much bigger platform than me, and they're starting to do the same stuff. And then they have their server side engine, the EmberCLI tool. The name is escaping me, but they have now a process where you can run the rendering on the server and node just the same as you can run the Ember app in the browser.

[00:04:06] And if you dig into the details of how that particular tool works, it's exactly the same ideas that I'm espousing here. Reusing the code in both places, doing initial page load render in the server, and then letting the app take over and progressively enhance to a single page app.

[00:04:22] That's exactly the same stuff I've been talking about here. It's an entirely compatible with the ideas that I've had with middle end for years. So I'm super excited even though Ember is maybe more overkill than I need. I'm super excited that a really smart group of people has come to similar conclusions and they're now pushing that forward.

[00:04:40] We're gonna see a lot more people get on that bandwagon I think cuz there's a lot of value to this simple idea of being able to share code and have it work yet. Fast boot that's exactly what it's talking about.
>> Student 2: People doing the same thing with react right now,

>> Kyle Simpson: Of course.
>> Student 2: Rendering the templates
>> Kyle Simpson: Yeah, absolutely.
>> Student 2: On both sides, and then the same with Angular. And I know Angular too right now, if you look at their reading notes, they're discussing this concept, I mean in detail I believe.
>> Kyle Simpson: So the good news is, over the next couple years basically everybody's gonna be doing it, okay?

>> Student 2: Yeah.
>> Kyle Simpson: And you can do it the simple way with no frameworks and just a little bit of code yourself. Or you can use a framework and the frameworks are gonna be doing it but the value is in the idea not the implementation.