Add pre and post template handling