luci-base: dispatcher: let attr() automatically serialize JSON
[project/luci.git] / modules / luci-base / luasrc / dispatcher.lua
index 91a4c63..c7903e6 100644 (file)
@@ -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