Razor 2 in MVC is smart enough to do it, but obviously not RazorGenerator.

The approach you've put in looks OK though :)