I try to write a statement with Razor syntax that use mvccontrib grid where a fluent interface makes statement in a long line. I want to scatter it in multiples lines like this:
@Html.Grid(Model).Columns(column =>
{
column.For(x => Html.ActionQueryLink(x.Name, "Edit", new { id = x.Id })).Named("Name");
column.For(x => x.Number).Named("Number");
}
).Attributes(@class => "grid-style"
).Empty("No data.")
Is it possible to put the parentheses that are at the beginning of the last two lines at the end of previous lines of each?
When I try to put the parentheses at the end of each line and try to start writing new line with a dot, this new line is interpreted like a text to raw output.
I find it odd that the new lines start with a parenthesis.
You just need to add an open parenthesis at the beginning of the code nugget. Change your code to:
On an aside, it’s generally considered better code style to begin new lines in a fluent interface with the dot, rather than the closing parentheses from the previous line. As in this example.