Andrew Nurse
Check me out on the web at my blog.
I work on the ASP.Net on the Razor parser!
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Andrew Nurse: Inside "Razor"
Jul 26, 2010 at 2:16 PM1. We discussed a number of options and ended up feeling that "@" was cleaner. In the end, every character has its downside from an escaping perspective, so there's no perfect character to choose
2. Right now, Razor is similar to ASPX in that it basically looks like option A. This is something we've thought a bit about, but it's not likely to improve in v1. The primary issue is that the markup indentation is something the parser would have to capture and pass on to the code somehow.
Andrew Nurse: Inside "Razor"
Jul 16, 2010 at 8:57 AMHey reinux, it's always cool to meet a fellow SFUer
. Razor has a system for plugging in new code languages that we haven't quite finished working out yet, but in the next releases I expect to be able to add better support for creating new code languages
without having to totally rewrite the parser. Obviously, as a code language developer, you'd have to implement the logic to parse blocks of the new language, but you'd still get quite a bit for free. Once that's cleaned-up a bit, one could absolutely add
F# support 
Andrew Nurse: Inside "Razor"
Jul 15, 2010 at 4:59 PMLooks like I was slow on the up-shot for the earlier reply and Erik beat me to it
. Btw, this is Andrew in case anyone is wondering, glad to hear your feedback on the Razor syntax and parser!
The issue here the HTML encoding that is auto-applied when printing variables like "@i". The contents of the <text> tag are considered HTML markup, and they can include HTML tags, we just don't render the outer <text> tag. So there's no need for a separate tag for markup, since markup is allowed within <text>.
Andrew Nurse: Inside "Razor"
Jul 15, 2010 at 4:53 PMIf you have a string with XML tags in it and pass it through "@", it will be HTML encoded. This is what I meant in the video when I mentioned that "@p" is like "<%: p %>" rather than "<%= p %>".
However, if you pass an IHtmlString through "@", it won't be HTML encoded. Right now, the easiest way to do this is:
@(new HtmlString("<p>Some text</p>"))We are considering a helper method, something like "Literal" which would do this wrapping for you, meaning you could write:
@{ var foo = "<p>Some text and markup</p>" } @Literal(foo)Just like in MVC, all of our helpers will output IHtmlString so you won't have to worry about them. When writing your own markup helpers, you should ensure they return some type that implements IHtmlString (I recommend System.Web.HtmlString
) so they
don't get encoded.