xml
XML module: build UI trees from XML markup.
<frame x="2" y="2" width="20" height="8">
<label text="Hello" foreground="#89b4fa"/>
<button text="Save" onClick="save"/>
<label text="{parent.width}"/> <!-- reactive works -->
</frame>local xml = basalt.use("xml")
xml.load(frame, xmlSource, { save = function(btn) ... end })Tag names map to add<Name>() on the parent (label -> addLabel), so any registered element works. Attribute values are converted: numbers, true/false, "#RRGGBB" -> basalt.rgb, "{...}" stays reactive, everything else is a string. on* attributes bind functions from the scope table.
Methods
xml.parse(src)
Parses an XML string into a tree of {tag, attrs, children, text} nodes.
src (
string) XML sourcereturns root (
table) Parsed root node
xml.load(parent, src, scope)
Builds elements from an XML string under parent.
parent (
table) The container the elements are added tosrc (
string) The XML markupscope (
table, optional) Functions referenced by on* attributesreturns elements (
table) The top-level created elements
xml.loadFile(parent, path, scope)
Like xml.load, but reads the markup from a file.
parent (
Container) Parent containerpath (
string) XML file pathscope (
table, optional) Event/function lookup scopereturns elements (
table) Top-level created elements