Handlebars
Handlebars
False--correct
____________ is fully logic-less but ___________ adds minimal logic by using some
helpers such as if, with, unless, each and more.
Mustache,Handlebars--correct
Library--correct
Mustache--correct
Templates can contain HTML and text, mixed with Handlebars expressions
True--correct
Hi {{name}}.
is used with the context variable:
var context = {
"name" : "<b>Jane Roe</b>"
}
<b>Jane Roe</b>--correct
False--correct
The variables are written in double curly braces {{}} are known as
___________________
expressions--correct
//Create your context here with employees array with name and contact number array
var context={
"employees" : [{"name" : "John Doe" , "contact" : ["2368968930", "0987897301"]}]
};
$(document).ready(function() {
//retrieving the template `handlebars-template` from the HTML
var theTemplateScript = $("#handlebars-template").html();
});
//Create your context here with students array with name and total_marks
var context = {
"students":[
{"name" : "John", "total_marks" : 505},
{"name" : "Doe" , "total_marks" : 205}
]
}
$(document).ready(function() {
//retrieving the template `handlebars-template` from the HTML
var theTemplateScript = $("#handlebars-template").html();
});
Handlebars.registerHelper()--correct
______________ are JS functions that you can call from your templates, and
encourage you to reuse code and build complex templates
Helpers--correct
The {{$ if}} helper allows you to implement an if condition block in your code.
False--correct
Built-in--correct
//Create a custom helper, 'SayGreetings' which returns fullname +', Good morning\Go
eat lunch\Good afternoon!' based on current time
Handlebars.registerHelper('SayGreetings', function(fullname){
var currentYear=new Date().getHours();
var b;
if(currentYear==12){
b=fullname+", Go eat lunch"
}else if(currentYear<12){
b=fullname+", Good morning"
}
else if(currentYear>12){
b=fullname+", Good afternoon!"
}
return b
});
//Create your context here with user with properties first_name and last_name
var context = {
"user": {'first_name':'John','last_name':'doe'}
}
$(document).ready(function() {
//retrieving the template `handlebars-template` from the HTML
var theTemplateScript = $("#handlebars-template").html();
});
parentheses--correct
______________ allows you to invoke multiple helpers in a single mustache.
Subexpression--correct
False--correct
How can you call the partial named customPartial in your template.
Handlebars.registerPartial()--correct
True
Template engines--wrong
____________ is a JSON object that contains the values of variables used in the
template.
context
True
True
True
options
The {{#unless}} helper only outputs the contained block if the given expression is
true.
False
Handlebars templates
False
No--correct
You can improve the execution of the application if you precompile templateScript
and then send the compiled version to the customer.
True
Options in custom block helper has a ________ method that allows you to change the
context of the object temporarily.
fn()
{{!TypeYourCommentHere}}
.handlebars