…The last thing we're going to look at in Mustache before…we move on, is the ability to define functions in Mustache.…And it's actually a really pretty cool feature.…So the way it works is this, if you have a set of data and if the value of a…field in the Jason is actually a function, Mustache will call that function.…And you can return from that function whatever you want…the data to be that will be inserted into the template.…
So you can see here in this example, I've got my data structure.…And I've got field1 and field2.…And one of them's a string.…One's a number.…And then I have a field called total.…And that's a function.…And all it's doing is taking the value of…the field1 and field2, and Mustache will set the…value of the this key word inside the function…to be the context of the data object itself.…That's why you can do this.…So, that's what will happen.…It will actually return the value of the function into the template.…
So Mustache will call this function, and you can pass back whatever you need to.…
- What is templating?
- Defining templates in jQuery Template
- Using simple Mustache templates with sections and conditions
- Adding conditionals and loops to Handlebars templates
- Working with Dust templates
Skill Level Intermediate
What is templating?5m 12s
2. jQuery Template
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.