Issue #2547159 by mdrummond, mortendk, davidhernandez, lauriii, joelpittet, Wim Leers, Cottser: menu class generating should be in the template not in a function