Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor line continuations

Tags:

razor

Is there anyway to make line continuations work in a razor view.

For example, the following code doesn't work

@Html.Grid(Model.Documents).Columns(column =>
{
    column.For(x => x.FleetNumber).Named("Fleet No.");
    column.For(x => x.OrderNumber).Named("Order No.");
    column.For(x => x.DateCreatedForDisplay).Named("Created").SortColumnName("DateCreated");
})
.Empty("Sorry, no documents were found")
.Attributes(@class => "datagrid")
.Sort(Model.Query.SortOptions())

I have to put the last three lines onto one single line

@Html.Grid(Model.Documents).Columns(column =>
{
    column.For(x => x.FleetNumber).Named("Fleet No.");
    column.For(x => x.OrderNumber).Named("Order No.");
    column.For(x => x.DateCreatedForDisplay).Named("Created").SortColumnName("DateCreated");
}).Empty("Sorry, no documents were found").Attributes(@class => "datagrid").Sort(Model.Query.SortOptions())
like image 463
kimsagro Avatar asked Feb 15 '11 01:02

kimsagro


1 Answers

You could denote that the whole thing is an expression like so:

@(Html.Grid(Model.Documents).Columns(column =>
{
    column.For(x => x.FleetNumber).Named("Fleet No.");
    column.For(x => x.OrderNumber).Named("Order No.");
    column.For(x => x.DateCreatedForDisplay).Named("Created").SortColumnName("DateCreated");
})
.Empty("Sorry, no documents were found")
.Attributes(@class => "datagrid")
.Sort(Model.Query.SortOptions()))

Note the additional parentheses.

like image 176
marcind Avatar answered Sep 27 '22 17:09

marcind