@@ -341,23 +341,36 @@ GET /t
341341 local Interpreter = Liquid. Interpreter
342342 local FileSystem = Liquid. FileSystem
343343 local InterpreterContext = Liquid. InterpreterContext
344- local var = {[" aa" ] = " -----" , [" bb" ] = { [" cc" ] = " ======" } }
345- local document = " { % if true % } abc{ { aa }} defg { % endif % } { % include ' foo' for bb % } { % include ' foo' % } "
346- local function mock_template()
347- return [[{% if true % } 12345 {{ cc }}6789 {% endif % }]]
344+ local var = {
345+ [" aa" ] = " -----" ,
346+ [" bb" ] = { [" cc" ] = " ======" },
347+ }
348+ local document = [[
349+ {% - if true -% }
350+ abc{{ aa }}defg
351+ {% - endif % }
352+ {% - include ' foo' for bb -% }
353+ {% - include ' foo' -% }
354+ {% - include ' bar' -% }
355+ ]]
356+ local filesystem = {
357+ foo = [[{% if true % } 12345 {{ cc }}6789 {% endif % }]],
358+ bar = [[{% include ' recursive' % }]],
359+ recursive = [[bar]],
360+ }
361+ local function mock_template(name )
362+ return filesystem[name ]
348363 end
349- FileSystem. get = mock_template
350364 local lexer = Lexer: new(document)
351365 local parser = Parser: new(lexer)
352366 local interpreter = Interpreter: new(parser)
353- ngx. say ( interpreter: interpret( InterpreterContext: new(var) ) )
367+ ngx. say ( interpreter: interpret( InterpreterContext: new(var), nil, nil, FileSystem : new(mock_template) ) )
354368 }
355369 }
356370-- - request
357371GET / t
358372-- - response_body
359- abc---- -defg 12345 ====== 6789 123456789
360-
373+ abc---- -defg 12345 ====== 6789 123456789 bar
361374-- - no_error_log
362375[error]
363376
0 commit comments