1. Handlebars is a front-end JS template engine that has its own syntax like other template engines such as PHP templates
{$foo} <--Display simple variable (non-array/ object) PHP smarty template engine div (class//Pug template engine // handlebars's template engine
2. Basic expressions
1 //The data are as follows:2 {3Title: "XXXXX",4 Person : {5Name: "Jack",6Age:30,7Hobbies: ["Football", "basketball", "Xbox"]8 }9 }Ten<div> One A<div>{{person.name}}</div>//support. Operator represents object properties -<div>{{person/age}}</div>//The same support/operator represents the object properties, but this writing has not been recommended, for official documents do not recommend the wording, be sure to remember not to use. -<ul> the{{#each person.hobbies as |hobby|}} -<li>{{hobby}}</li> -{{/each}} -</ul> +</div>
3. Special characters Disable marking
whitespace//Space, tab, carriage return line
When referencing an illegal identity, you can use the [Reference property, as follows:
1 {{#each articles.[ ). [#comments]}} 2 3 <div>4 {{body}}5 </div>6 {{/each}}
The above loop is the following variable
1 articles[10][' #comments ']
4. Escaping and prohibiting escaping
{ "}<div> <p> escaped display </p> {{H1}} </div><div> <p> Disable escaping, what is output as-is </p> {{{ h1}}}</div>
The output is as follows:
{ "}<div> <p> escaped presentation </p> %3ch1% 3egood%3c/h1%3e</div><div> <p> Forbidden escape, what is output as-is </p>
Write these first, and the next chapter should learn some helpers and sub-expressions.
JS Template engine Handlebars Learning (i)