This is what I used in oUF_Donut just to play around with templates:
Lua Code:
--get the addon namespace
local addon, ns = ...
--object container
local tmp = CreateFrame("Frame")
ns.tmp = tmp
---------------------------------------------
-- variables
---------------------------------------------
tmp.styles = {}
---------------------------------------------
-- template functions
---------------------------------------------
--template RegisterTemplateByName
function tmp:RegisterTemplateByName(name,data)
tmp.styles[name] = data
end
--template UnregisterTemplateByName
function tmp:UnregisterTemplateByName(name)
tmp.styles[name] = nil
end
--template GetTemplateByName
function tmp:GetTemplateByName(name)
return tmp.styles[name]
end
If you make your templating object global any addon could use them.
Another way is adding new templating or skinning functions to specific frame meta tables. !BeautyCase does this for example. That way you add functions to the default wow api via progressive enhancement.
http://code.google.com/p/rothui/sour...ore/lib.lua#84
Lua Code:
local frame = FRAME_BY_GLOBALNAME or CreateFrame("Frame")
local mt = getmetatable(frame).__index
mt.SkinFrame = function(self,name,data)
--do stuff
end
frame:SkinFrame("name", {})
I'm in no way an expert on that topic but it got the job done for what I needed.