admin - refactoring template editor

The code needed some changes to be more friendly when adding a new
template mode (like email or app). A good start today.