-
Notifications
You must be signed in to change notification settings - Fork 0
Comparison
Jacob Jensen edited this page May 24, 2016
·
3 revisions
Based on: http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/
@{
int x = 123;
string y = "because.";
}
@{
int x = 123;
string y = "because.";
}
<span>@model.Message</span>
@(Text to encode)
Diamond will not escape variables. However they can be escaped with the escape function.
@:escape(model.message);
In 0.2.4 it'll be possible to escape variables / expressions using the syntax @$=model.message;
<span>
@Html.Raw(model.Message)
</span>
<span>
@=model.message;
</span>
@foreach(var item in items) {
<span>@item.Prop</span>
}
@:foreach(item; items) {
<span>@=item.prop;</span>
}
@if (foo) {
<text>Plain Text</text>
}
@:if (foo) {
<text>Plain Text</text>
}
@if (foo) {
@:Plain Text is @bar
}
@:if (foo) {
Plain Text is @@bar;
}
<span>ISBN@(isbnNumber)</span>
<span>ISBN@=isbnNumber;</span>
<span>In Razor, you use the @@foo to display the value of foo</span>
Some cases might let you write @ and not @@
<span>In Diamond, you use the @@foo to display the value of foo</span>
@*
This is a server side
multiline comment
*@
@*
This is a server side
multiline comment
*
@(MyClass.MyMethod<AType>())
@:MyClass.myMethod!AType();
@{
Func<dynamic, object> b =
@<strong>@item</strong>;
}
@b("Bold this");
*In Diamond it isn't necessary to create delegates. Diamond let's you integrate any D code and thus you can create normal functions
@:void b(T)(T item) {
<strong>@=item;</strong>
}
@:b("Bold this");
Hello @title. @name.
Hello @=title;. @=name;.