In certain narrow cases, XML is 'mandatory' if you need to absolutely need to create an XML template. Examples would be pins on the 8.0.1 world map; I don't think that can be done without an XML file (that is just three lines long).
Otherwise... you just have to go from this paradigm:
Code:
<Frame name="MyTemplate" virtual="true" hidden="true">
<Scripts>
<OnShow>
print("see me now?")
</OnShow>
</Script>
<!-- insert other stuff here to control its appearance -->
</Frame>
<Frame name="MyFrame1" implements="MyTemplate" id="1"></Frame>
<Frame name="MyFrame2" implements="MyTemplate" id="2"></Frame>
<Frame name="MyFrame3" implements="MyTemplate" id="3"></Frame>
To this one:
Lua Code:
local function createMyFrame(id)
local frame = CreateFrame("Frame")
local frame:Hide()
frame:SetID(id)
frame:SetScript("OnShow", function()
print("see me now?")
end)
-- insert other stuff here to control its appearance
return frame
end
local myFrame1 = createMyFrame(1)
local myFrame2 = createMyFrame(2)
local myFrame3 = createMyFrame(3)
But I would echo Fizzlemizz's remarks... there's nothing wrong with leaving something in XML if its already done.
Therefore, I would only advise converting it to Lua if you were making a more substantial change in the process.