Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a trim function for razor?

I am outputting data to a table like the following:

foreach (var attr in item.attr_type)
{
  <td>
     @foreach (var attrs in attr.attr_value)
     {
       @attrs                            
     }              
</td>                 
}

If there a trim function i can put around @attrs because alot of white space is created

like image 367
Beginner Avatar asked Jan 26 '12 11:01

Beginner


1 Answers

Not sure what type attrs is, but:

@foreach (var attrs in attr.attr_value)
 {
       @(attrs.ToString().Trim())//should work?                            
 }

If it doesn't, you can/should, override toString() in your attrs type.

Note: @(..) does output an HTML-encoded string.

like image 146
gideon Avatar answered Oct 13 '22 10:10

gideon