I’m trying to generate fairly simple xml using razor template engine.
This is my template:
<gridDef Id="@Model.MasterType.Name"/>
I would like to append “Grid” to Id attribute value.
It works with code block:
@{
var name = Model.MasterType.Name + "Grid";
}
<gridDef Id="@name"/>
but I would like to use razor syntax without defining variables. Is that possible?
You need to use parentheses to separate the Razor expression from the literal source:
Alternatively, you could concatenate the string within the expression: