Good:
@* Comment *@
Bad:
<!-- Comment -->
@* Comment *@
<!-- Comment -->
MVC has a bunch of handy helpers that we can use to create our views more efficiently. One such helper are the display templates that are used within views.
@Html.DisplayFor(e => e.Username)
The DisplayFor(Func<TModel, TValue> expression) function uses the type of the property in the expression to display the property value.
<!-- DisplayFor on string UserName = "daniel.imms" --> <span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true">daniel.imms</span>
<umbraco:Macro runat="server" Language="razor">
@{
// insert razor here
var href = "index.htm";
<a href="@href">Home</a>
}
</umbraco:Macro>
This should only be done for small one-offs where you are unlikely to need to reuse the functionality, such as loading in the page title. Keep anything greater than that in the scripting folder.
@functions
{
HtmlString PrintSomething()
{
return new HtmlString("Hello World");
}
}
Returning a HtmlString object will allow you to print to the screen.<div>@PrintSomething()</div>