I am using ASP.NET MVC 4 and would like to know if there is a way to compile a Razor view into JavaScript? This means that I want to create the HTML in JavaScript! This would allow the Controller to respond with either HTML or JSON, depending on the request, allowing me to minimize the bandwidth and CPU requirements while serving pages faster to each client. Is there such a compilation option (where I imagine that HTML helpers are actually ran, before compiling into JavaScript), or, is there a JavaScript interpreter for Razor syntax?
Share
There’s currently a project called
RazorClientTemplatesthat compiles Razor views into JavaScript.I use it in an MVC 3 project, with Backbone — and it works, but support for code blocks and HTML helpers are very limited.