diff options
Diffstat (limited to 'lib/ajaxlib.lua')
-rw-r--r-- | lib/ajaxlib.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/ajaxlib.lua b/lib/ajaxlib.lua index e51d74f..7a8a395 100644 --- a/lib/ajaxlib.lua +++ b/lib/ajaxlib.lua @@ -33,6 +33,18 @@ function ajax_escape(str) return generic_escape(str, ajax_replacements) end +local function toajax(val) + local t = type(val) + + if t == "nil" or t == "function" or t == "table" then + return "" + elseif t == "boolean" then + return v and "1" or "0" + else + return val + end +end + function ajax_dump_table(t, out) local k, v, vk, vv @@ -43,7 +55,7 @@ function ajax_dump_table(t, out) for k, v in pairs(t) do out:write(k) for vk, vv in pairs(v) do - out:write("|" .. ajax_escape(vk) .. "=" .. ajax_escape(vv)) + out:write("|" .. ajax_escape(toajax(vk)) .. "=" .. ajax_escape(toajax(vv))) end out:write("\n") end |