These days it would be done using a Mixin eg.
XML
Code:
<Button name="AchievementFullSearchResultsButtonTemplate" mixin="AchievementFullSearchResultsButtonMixin" virtual="true">
Lua
Lua Code:
AchievementFullSearchResultsButtonMixin = {};
function AchievementFullSearchResultsButtonMixin:Init(elementData)
-- ...
end
This would "apply" any function defined in the AchievementFullSearchResultsButtonMixin table as a method of the button when the frame using the template is created.