move template compilation into controller