-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Liquid: Fix issues with non-alphanumeric keys
Fix #17 Signed-off-by: Eloy Coto <[email protected]>
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use Test::Nginx::Socket 'no_plan'; | ||
use Cwd qw(cwd); | ||
|
||
my $pwd = cwd(); | ||
|
||
our $HttpConfig = qq{ | ||
lua_package_path "$pwd/lib/?.lua;;;"; | ||
lua_package_cpath "/usr/local/openresty/lualib/?.so;;"; | ||
}; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: get filter. | ||
--- http_config eval: $::HttpConfig | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local context = {} | ||
context.foo = "123" | ||
local Liquid = require 'liquid' | ||
local document = 'SELF::{{ self | first | get: "foo" }}' | ||
local template = Liquid.Template:parse(document) | ||
ngx.say(template:render( Liquid.InterpreterContext:new(context))) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
SELF::123 | ||
=== TEST 2: get filter with non alphanumeric keys | ||
--- http_config eval: $::HttpConfig | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local context = {} | ||
context["foo/bar"] = "123" | ||
local Liquid = require 'liquid' | ||
local document = 'SELF::{{ self | first | get: "foo/bar" }}' | ||
local template = Liquid.Template:parse(document) | ||
ngx.say(template:render( Liquid.InterpreterContext:new(context))) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
SELF::123 |