moved menu logic from template to views