Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Add test case for template 'for' syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
mytharcher committed Aug 7, 2012
1 parent 15e23cd commit 919e871
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ test("merge", function() {
er.template.merge( el, 'mergeTest6_3' );
equals(el.innerHTML, '1,0|2,1|3,2|4,3|5,4', 'merge,for遍历数组,带数组索引');

er.template.parse('<!-- target:mergeTest6_4 --><!-- for: ${myObject.myList} as ${item} -->${item}<!-- /for -->');
er.context.set( 'myObject', {myList: [1,2,3,4,5]} );
er.template.merge( el, 'mergeTest6_4' );
equals(el.innerHTML, '12345', 'for遍历多级对象数组');

er.template.parse('<!-- target:mergeTest7 --><!-- if: ${num} > 0 -->${num}<!--elif: ${num} == 0-->zero<!--else-->invalid<!-- /if -->');
er.context.set( 'num', 1 );
er.template.merge( el, 'mergeTest7' );
Expand Down

0 comments on commit 919e871

Please sign in to comment.