Skip to content

Commit

Permalink
Liquid: Fix issues with non-alphanumeric keys
Browse files Browse the repository at this point in the history
Fix chenxianyu2015#17

Signed-off-by: Eloy Coto <[email protected]>
  • Loading branch information
eloycoto committed Jan 15, 2020
1 parent 58e0a19 commit 2b4a115
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/liquid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2510,6 +2510,12 @@ function InterpreterContext:find_var( name )
if name == nil then
error("Invalid var name")
end

-- Just returns the full context if the value if self.
if name == "self" then
return self.stackframe
end

local value = nil
local length = #(self.stackframe)
local step = -1
Expand Down Expand Up @@ -2978,8 +2984,16 @@ local function json( obj )
-- body
return cjson.encode(obj)
end


local function get(obj, key)
return obj[key]
end

--=== Additional filter end



--========================================================== add filers to FilterSet instance================================
--Array filter
FilterSet:add_filter("join", join )
Expand Down Expand Up @@ -3025,7 +3039,7 @@ FilterSet:add_filter("str_reverse", str_reverse )

--Additinal filter
FilterSet:add_filter("json", json )

FilterSet:add_filter("get", get)



Expand Down

0 comments on commit 2b4a115

Please sign in to comment.