Added callbacks before and after template insert

Added two options, beforeInsert and afterInsert, that are callback
functions that will be called before inserting the element into the DOM,
and after inserting the element into the DOM.