Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White (blank, empty) space between values in an IF condition { }

Simple question and probably simple answer, but I've tried a lot of things.

How can I insert a white space between the 2 values ?

I have tried quotation mark, double quotation mark, removing the ";", &nbsp, etc

@if(@providerData.CompanyName != null){

    @providerData.CompanyName;WHITESPACE;@providerData.CompanyType;
}
like image 902
user1455103 Avatar asked Dec 27 '22 17:12

user1455103


2 Answers

You may use Html.Raw method to put a white space there

@if(@providerData.CompanyName != null)
{
  @[email protected](" ")@providerData.CompanyType    
}

Alternatively you can use @: instead of Html.Raw

@if(@providerData.CompanyName != null)
{
  @providerData.CompanyName@: @providerData.CompanyType    
}
like image 70
Shyju Avatar answered Dec 29 '22 06:12

Shyju


This is a very old question now, but there's one more possible solution for the problem - use the <text> tag for this purpose. This tag itself won't be printed to your output but it will preserve the formatting you have inside of it.

@if(@providerData.CompanyName != null)
{
    <text>@providerData.CompanyName @providerData.CompanyType</text>
}

I think this way provides the cleanest syntax for what you want to achieve.

like image 25
RaYell Avatar answered Dec 29 '22 07:12

RaYell