3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
8 Ext.test.session.addTest( 'Ext', new Y.Test.Case({
15 test_apply: function() {
43 var tpl1 = new Ext.XTemplate( '{hello} {world}. <tpl for="items1">{.}{[ xindex === xcount ? "" : ":" ]}</tpl>', { compiled: true });
44 Y.Assert.areEqual( 'Hello World. test1:test2:test3', tpl1.apply( data ), 'Test apply with an object with an array' );
46 var tpl2 = new Ext.XTemplate( '<tpl for="items2">{name}{[ xindex === xcount ? "" : ":" ]}</tpl>', { compiled: true });
47 Y.Assert.areEqual( 'test1:test2:test3', tpl2.apply( data ), 'Test apply with an object with an array of hashes' );
49 var tpl3 = new Ext.XTemplate(
50 '<ul><tpl for="kids">',
51 '<tpl if="this.isGirl(gender)">',
52 '<li>Girl: {name} - {age}</li>',
54 '<tpl if="!this.isGirl(gender)">',
55 '<tpl if="age < 1">',
56 '<li>Baby Boy: {name} - {age*12} months</li>',
58 '<tpl if="age >= 1">',
59 '<li>Boy: {name} - {age}</li>',
66 isGirl: function(gender){
71 Y.Assert.areEqual( '<ul><li>Girl: Sara Grace - 3</li><li>Boy: Zachary - 2</li><li>Baby Boy: John James - 6 months</li></ul>',
72 tpl3.apply( data ), 'Test apply with template member functions, basic comparison operators, and math' );
75 // apply is an alias for applyTemplate