How can I change razor syntax in RazorEngine?
I need to use specific keyword instead of"@"
symbol.
For example: $$Model.someField
instead of @Model.someField
. ("$$"
instead of "@"
).
You can't. Razor is not really designed in a way to do it. Basically (Microsoft.AspNet.)Razor has some specially written parsers which handle "@" in a special manner (by switching parsers). This means the languages (C#, Html in this case) itself need to be compatible with this procedure as well!
If you want to replace "@" with something else you need to rewrite the Razor Parsers. This is possible, but at this point you already implemented the hardest part of Razor yourself...
The real question you should ask yourself (or answer here) is: Why you want to do it? It is not as trivial as one would think, I was at this point before.
As freedomn-m suggested you should use @Html.Raw("@") or @@ if you need to output a "@".
matthid - a RazorEngine contributor