diff options
author | alyx <alyx@aleteoryx.me> | 2024-04-05 17:27:46 -0400 |
---|---|---|
committer | alyx <alyx@aleteoryx.me> | 2024-04-05 17:27:46 -0400 |
commit | 79999cecedd84e99655fbcdba0bd4e715a22173f (patch) | |
tree | 0a14c94c92d196c1bf73f2648c2ebacfe6a03500 /src/theming/lua-lib | |
parent | ca7c46e535ac60a976a8c60477fa9424c46b6e3f (diff) | |
download | lfm_embed-79999cecedd84e99655fbcdba0bd4e715a22173f.tar.gz lfm_embed-79999cecedd84e99655fbcdba0bd4e715a22173f.tar.bz2 lfm_embed-79999cecedd84e99655fbcdba0bd4e715a22173f.zip |
Lua support feature-complete
Full implementation of debug mode still pending
Diffstat (limited to 'src/theming/lua-lib')
-rw-r--r-- | src/theming/lua-lib/expect.lua | 6 | ||||
-rw-r--r-- | src/theming/lua-lib/html.lua | 14 |
2 files changed, 13 insertions, 7 deletions
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 }) |