From 79999cecedd84e99655fbcdba0bd4e715a22173f Mon Sep 17 00:00:00 2001 From: alyx Date: Fri, 5 Apr 2024 17:27:46 -0400 Subject: Lua support feature-complete Full implementation of debug mode still pending --- src/theming/lua-lib/expect.lua | 6 +++--- src/theming/lua-lib/html.lua | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/theming/lua-lib') diff --git a/src/theming/lua-lib/expect.lua b/src/theming/lua-lib/expect.lua index 9afbb49..20772b2 100644 --- a/src/theming/lua-lib/expect.lua +++ b/src/theming/lua-lib/expect.lua @@ -50,7 +50,7 @@ local function get_display_type(value, t) -- Cobalt and only read the metatable for tables/userdata. if t ~= "table" and t ~= "userdata" then return t end - local metatable = debug.getmetatable(value) + local metatable = getmetatable(value) if not metatable then return t end local name = rawget(metatable, "__name") @@ -72,8 +72,8 @@ local function expect(index, value, ...) -- If we can determine the function name with a high level of confidence, try to include it. local name - local ok, info = pcall(debug.getinfo, 3, "nS") - if ok and info.name and info.name ~= "" and info.what ~= "C" then name = info.name end + -- local ok, info = pcall(debug.getinfo, 3, "nS") + -- if ok and info.name and info.name ~= "" and info.what ~= "C" then name = info.name end t = get_display_type(value, t) diff --git a/src/theming/lua-lib/html.lua b/src/theming/lua-lib/html.lua index 386618b..6786f96 100644 --- a/src/theming/lua-lib/html.lua +++ b/src/theming/lua-lib/html.lua @@ -16,8 +16,8 @@ local function html(el, tbl) expect(1, el, "string") expect(2, tbl, "table") - innerHtml = "" - attributes = "" + local innerHtml = "" + local attributes = "" for k, v in pairs(tbl) do if type(k) == "string" then @@ -39,6 +39,12 @@ local function root(tbl) end return setmetatable( - { root = root }, + {}, { __call = html, - __index = function (idx) return function(tbl) html(idx, tbl) end end }) + __index = function (_, idx) + if idx == "root" then + return root + else + return function(tbl) return html(idx, tbl) end + end + end }) -- cgit v1.2.3-54-g00ecf