kissyteam / kissy

A Powerful Collection Of Modules
http://docs.kissyui.com
2.7k stars 862 forks source link

xtemplate: support elseif #664

Closed yiminghe closed 10 years ago

yiminghe commented 10 years ago

support elseif

http://jsfiddle.net/yiminghe/ka2ua/

var tpl = '{{#if(x===1)}} 1 {{elseif (x===2)}} 2 {{elseif (x===3)}} 3 {{else}} ! {{/if}}';
var render = new XTemplate(tpl).render({
    x: 1
});
expect(render).toBe(' 1 ');
render = new XTemplate(tpl).render({
    x: 2
});
expect(render).toBe(' 2 ');
render = new XTemplate(tpl).render({
    x: 3
});
expect(render).toBe(' 3 ');
render = new XTemplate(tpl).render({
    x: 4
});
expect(render).toBe(' ! ');