📜  把手 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:12.255000             🧑  作者: Mango

代码示例1
var source = "

Hello, my name is {{name}}. I am from {{hometown}}. I have " + "{{kids.length}} kids:

" + "
    {{#kids}}
  • {{name}} is {{age}}
  • {{/kids}}
"; var template = Handlebars.compile(source); var data = { "name": "Alan", "hometown": "Somewhere, TX", "kids": [{"name": "Jimmy", "age": "12"}, {"name": "Sally", "age": "4"}]}; var result = template(data); // Would render: //

Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids:

//
    //
  • Jimmy is 12
  • //
  • Sally is 4
  • //