@@ -85,22 +85,6 @@ describe('data', function() {
85
85
equals ( "Hello undefined" , result , "@foo as a parameter retrieves template data" ) ;
86
86
} ) ;
87
87
88
- it ( "parameter data throws when using this scope references" , function ( ) {
89
- var string = "{{#goodbyes}}{{text}} cruel {{@./name}}! {{/goodbyes}}" ;
90
-
91
- shouldThrow ( function ( ) {
92
- CompilerContext . compile ( string ) ;
93
- } , Error ) ;
94
- } ) ;
95
-
96
- it ( "parameter data throws when using parent scope references" , function ( ) {
97
- var string = "{{#goodbyes}}{{text}} cruel {{@../name}}! {{/goodbyes}}" ;
98
-
99
- shouldThrow ( function ( ) {
100
- CompilerContext . compile ( string ) ;
101
- } , Error ) ;
102
- } ) ;
103
-
104
88
it ( "parameter data throws when using complex scope references" , function ( ) {
105
89
var string = "{{#goodbyes}}{{text}} cruel {{@foo/../name}}! {{/goodbyes}}" ;
106
90
@@ -251,4 +235,23 @@ describe('data', function() {
251
235
equals ( 'hello' , result ) ;
252
236
} ) ;
253
237
} ) ;
238
+
239
+ describe ( 'nesting' , function ( ) {
240
+ it ( 'the root context can be looked up via @root' , function ( ) {
241
+ var template = CompilerContext . compile ( '{{#helper}}{{#helper}}{{@./depth}} {{@../depth}} {{@../../depth}}{{/helper}}{{/helper}}' ) ;
242
+ var result = template ( { foo : 'hello' } , {
243
+ helpers : {
244
+ helper : function ( options ) {
245
+ var frame = Handlebars . createFrame ( options . data ) ;
246
+ frame . depth = options . data . depth + 1 ;
247
+ return options . fn ( this , { data : frame } ) ;
248
+ }
249
+ } ,
250
+ data : {
251
+ depth : 0
252
+ }
253
+ } ) ;
254
+ equals ( '2 1 0' , result ) ;
255
+ } ) ;
256
+ } ) ;
254
257
} ) ;
0 commit comments