@:Hello World! is essentially the same as <text>Hello World</text>
and
@Model.pageTitle is the same as doing <%= Model.pageTitle%>
Basically Razor consist of 2 parsers the Markup parser and the Code parser, both parsers can identify markeup and code but only the respective parsers can render or parse markup or code. These 2 parsers call into each other so form a stack when rendering a page. When a particluar parser gets called it will also know what it's "end" is, so the makrup parser knows that if it encountewrs a <li> tag then the end of that markup block will be a </li> tag. Here is an example of how the stack works with the markup parser (MP) and the code parser (CP).
<p><-----stack: MP <-call into markup parser @foreach (dynamic node in Model.Childen)<-----stack: MP - CP<-Markup parser calls into code parser { <a href="#"><-----stack: MP - CP - MP My Link at @DateTime.Now<-----stack: MP - CP - MP - CP <- the end of this code block is the space after the "Now" Back to markup<-----stack: MP - CP - MP </a><-----stack: MP - CP }<- end of code block so code parser ends </p> <-----stack: MP
I hope that makes a bit of sense, and whilst I believe that is correct it is only my understanding so might be entirely werong! ;-)
So to anser your question, you should be able to do
thanks for such a fantastic and detailed explanation! yes still very much trying to get the hang of razor! I love how clean it is.. it's just the syntax and when to use certain things that are throwing me.. like the example of the sitemap where you can declare a helper like traverse!
can you also @using somelibrary.web and just call methods using it?
@Tom: no problem, still learning it myself so it's good to think things through! As far as I am aware you can do pretty much anything that you could do in C# ASP.NET. So yes you can definitely do @using somelibrary.
HTML Raw with @: syntax
Hi guys.
still trying to get used to the whole razor syntax just wodnering how I'd Html.Raw something like: @:@Model.pageTitle | Site Name
I've tried @:Html.Raw(@Mode.pageTitle | Site Name) but i just can't get it out..
Hi Tom,
@:Hello World! is essentially the same as <text>Hello World</text>
and
@Model.pageTitle is the same as doing <%= Model.pageTitle%>
Basically Razor consist of 2 parsers the Markup parser and the Code parser, both parsers can identify markeup and code but only the respective parsers can render or parse markup or code. These 2 parsers call into each other so form a stack when rendering a page. When a particluar parser gets called it will also know what it's "end" is, so the makrup parser knows that if it encountewrs a <li> tag then the end of that markup block will be a </li> tag. Here is an example of how the stack works with the markup parser (MP) and the code parser (CP).
I hope that makes a bit of sense, and whilst I believe that is correct it is only my understanding so might be entirely werong! ;-)
So to anser your question, you should be able to do
Hi Alex,
thanks for such a fantastic and detailed explanation! yes still very much trying to get the hang of razor! I love how clean it is.. it's just the syntax and when to use certain things that are throwing me.. like the example of the sitemap where you can declare a helper like traverse!
can you also @using somelibrary.web and just call methods using it?
Cheers,
Tom
@Tom: no problem, still learning it myself so it's good to think things through! As far as I am aware you can do pretty much anything that you could do in C# ASP.NET. So yes you can definitely do @using somelibrary.
is working on a reply...