More On Razor Syntax / Expressions

This post gets enough said about how the Razor parser works.,guid,89b7bd90-52d7-4d49-b87d-4e888f285b4c.aspx

The guy, Andrew Nurse, is the one who wrote the parser!   (from Haack’s note)


After reading it and a quick chat with @Haacked on twitter, it seems all your “escape” kind of Razor expressions (that is meaning: when mixing code and text without spaces etc…) will look like @(someCode)someText. This is coming from an example, to escape a C# identifier that’s also a keyword, say “class”, you’d be using @(@class). The @(…) style is the new <%: … %> but only required for escape situations.


Also, it seems that switching from being equivalent to <%: … %> to being equivalent to <%= … %> by using some Razor notation is not gonna make it. You need to do it through doing some classes implementing IHtmlString interface.


Of course I’m not so sure that’s exactly the case. Anyway, Razor is only available now in WebMatrix mini-IDE, not much MVC love yet (pretty soon).  Just thought it might be interesting…

Share With Friends:

How did I learn that?

As a bonus for coming here, I'm giving away a free newsletter for web developers that you can sign up for from here.

It's not an anything-and-everything link list. It's thoughtfully collected picks of articles and tools, that focus on Angular 2+, ASP.NET (4.x/MVC5 and Core), and other fullstack developer goodies.

Take it for a test ride, and you may unsubscribe any time.

You might also want to support me by checking these out [Thanks]: