+ local function ifattr(cond, key, val)
+ if cond then
+ local env = getfenv(1)
+ return string.format(
+ ' %s="%s"', tostring(key),
+ luci.util.pcdata(tostring( val
+ or (type(env[key]) ~= "function" and env[key])
+ or "" ))
+ )
+ else
+ return ''
+ end
+ end
+