开发者

Razor reseverd words

That the razor syntax is neat, there's little arguing about. But i can't seem to find it anywhere...

What are the razor reserved words?

@using

@inherits

@functions

开发者_如何转开发 @section

Do you know any other?


Here's a list of Razor reserved keywords (Note: This applies to cshtml, vbhtml follows VB's rules):

Razor-specific keywords

  • inherits
  • functions
  • section
  • helper
  • model (only in MVC projects)

You can escape these using @(inherits)

Language-specific Razor keywords

These are C# keywords that are understood by Razor

  • if
  • do
  • try
  • for
  • foreach
  • while
  • switch
  • lock
  • using
  • case
  • default

You can escape them using @(@lock) (first @ is used to escape the Razor parser and the second @ is used to escape the C# parser)

Reserved keywords

These are not reserved in RC but will be for RTM. Update: These will have no functionality for RTM. They are simply reserved for future use.

  • namespace
  • class
  • layout


You've got them all. The only one I know of that's in the RC is @model but I don't see that in the list of RazorKeywords from the source so I'm not sure how that one is used or parsed.

If you check the source file "CSharpCodeParser.cs" under the WebPages/System.Web.Razor project you'll find a list of RazorKeywords.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜