This commit is contained in:
Sabine Lim
2023-05-28 17:47:06 +10:00
committed by GitHub
parent f7e55c9f52
commit 716debd419

View File

@@ -36,7 +36,24 @@ end
return {
basalt = function(basalt)
local createObjectsFromXMLNode = function(node, env)
local object = {
observable = Reactive.observable,
derived = Reactive.derived,
effect = Reactive.effect,
transaction = Reactive.transaction,
untracked = Reactive.untracked,
layout = function(path)
if (not fs.exists(path)) then
error("Can't open file " .. path)
end
local f = fs.open(path, "r")
local text = f.readAll()
f.close()
return Layout.fromXML(text)
end,
createObjectsFromXMLNode = function(node, env)
local layout = env[node.tag]
if (layout ~= nil) then
local props = {}
@@ -65,23 +82,6 @@ return {
end
end
return {object}
end
local object = {
observable = Reactive.observable,
derived = Reactive.derived,
effect = Reactive.effect,
transaction = Reactive.transaction,
untracked = Reactive.untracked,
layout = function(path)
if (not fs.exists(path)) then
error("Can't open file " .. path)
end
local f = fs.open(path, "r")
local text = f.readAll()
f.close()
return Layout.fromXML(text)
end,
createObjectsFromLayout = function(layout, props)
@@ -105,7 +105,7 @@ return {
end
local objects = {}
for _, node in ipairs(layout.nodes) do
local _objects = createObjectsFromXMLNode(node, env)
local _objects = basalt.createObjectsFromXMLNode(node, env)
for _, object in ipairs(_objects) do
table.insert(objects, object)
end