Do not confuse programming code and code to display a property. It is bad practice to put programming code in a markup file. However the code you are showing is code used to make the markup.
MVC should be treated as a normal MVC framework and all logic code should be in the Controller.