From 8f409a45abb8cc4fda068c6a24085c467f3e37d8 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 10 Feb 2016 19:30:43 +0100 Subject: [PATCH] luci-base: dispatcher: let attr() automatically serialize JSON Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/dispatcher.lua | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.25.1