-
Book Overview & Buying
-
Table Of Contents
Blazor WebAssembly by Example - Third Edition
By :
Razor syntax combines C#, HTML and Razor markup. Razor markup refers to the special syntax elements that start with an @. Razor syntax uses both inline expressions and control structures to render dynamic content.
Inline expressions start with an @ symbol followed by a variable or function name. This is an example of an inline expression:
<h1>Blazor is @Text!</h1>
In the preceding example, Blazor interprets the text after the @ symbol as either a property name or a method name.
To display a literal @ symbol, use a double @@.
Control structures direct program flow by evaluating conditions and choosing which code to execute. They also start with an @ symbol. The content within the curly { } brackets is evaluated and rendered to the output. This is an example of an if statement from the Weather component in the Demo project that you will create later in this chapter:
@if (forecasts == null)
{
<p><em>Loading...