Fix (#90)
This commit is contained in:
@@ -36,7 +36,24 @@ end
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
basalt = function(basalt)
|
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]
|
local layout = env[node.tag]
|
||||||
if (layout ~= nil) then
|
if (layout ~= nil) then
|
||||||
local props = {}
|
local props = {}
|
||||||
@@ -65,23 +82,6 @@ return {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return {object}
|
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,
|
end,
|
||||||
|
|
||||||
createObjectsFromLayout = function(layout, props)
|
createObjectsFromLayout = function(layout, props)
|
||||||
@@ -105,7 +105,7 @@ return {
|
|||||||
end
|
end
|
||||||
local objects = {}
|
local objects = {}
|
||||||
for _, node in ipairs(layout.nodes) do
|
for _, node in ipairs(layout.nodes) do
|
||||||
local _objects = createObjectsFromXMLNode(node, env)
|
local _objects = basalt.createObjectsFromXMLNode(node, env)
|
||||||
for _, object in ipairs(_objects) do
|
for _, object in ipairs(_objects) do
|
||||||
table.insert(objects, object)
|
table.insert(objects, object)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user