From: Jo-Philipp Wich Date: Wed, 10 Feb 2016 18:30:43 +0000 (+0100) Subject: luci-base: dispatcher: let attr() automatically serialize JSON X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=8f409a45abb8cc4fda068c6a24085c467f3e37d8 luci-base: dispatcher: let attr() automatically serialize JSON Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua index 91a4c63a6..c7903e638 100644 --- a/modules/luci-base/luasrc/dispatcher.lua +++ b/modules/luci-base/luasrc/dispatcher.lua @@ -273,6 +273,13 @@ function dispatch(request) if cond then local env = getfenv(3) local scope = (type(env.self) == "table") and env.self + if type(val) == "table" then + if not next(val) then + return '' + else + val = util.serialize_json(val) + end + end return string.format( ' %s="%s"', tostring(key), util.pcdata(tostring( val