2017年5月16日 星期二

mustache

if
{{#print}}
    {{#beatles}}
        <p>{{name}}</p>
    {{/beatles}}
{{/print}}
------------------------------------
else
{{^print}}
    {{#beatles}}
        <p>no print: {{name}}</p>
    {{/beatles}}
{{/print}}

viewData =
{
            print: true,
            beatles: [
                { "firstName": "John", "lastName": "Lennon" },
                { "firstName": "Paul", "lastName": "McCartney" },
                { "firstName": "George", "lastName": "Harrison" },
                { "firstName": "Ringo", "lastName": "Starr" }
            ],
            name: function () {
                return this.firstName + " " + this.lastName;
            }
        }