+ Start a Discussion
Tyler ZikaTyler Zika 

Embed styling into Visualforce if statement

I want to add style to the output of a Visualforce IF statement.
 
<li>{! IF( ISBLANK(GoEvent.Event_Time_End__c), '', "End Time: "+GoEvent.Event_Time_End__c+"" ) }</li>

How would I add bold tags to End Time: (<b>End Time: </b>) ?

When I do add bold tags in the if statement it takes them as a string and doesn't style it as bold.
Best Answer chosen by Tyler Zika
Bryan JamesBryan James
you could use an apex:outputtext and the escape attribute set to false
<apex:outputText value="{! IF( ISBLANK(Contact.Owner.Email), '', "<b>End Time:</b> "+Contact.Owner.Email+"" ) }" escape="false"/>

All Answers

Bryan JamesBryan James
Inside your li tag put  style='{! IF( ISBLANK(GoEvent.Event_Time_End__c), "", "font-weight:bold;" ) }'
so it reads <li style='{! IF( ISBLANK(GoEvent.Event_Time_End__c), "", "font-weight:bold;" ) }'>{! IF( ISBLANK(GoEvent.Event_Time_End__c), '', "End Time: "+GoEvent.Event_Time_End__c+"" ) }</li>
Tyler ZikaTyler Zika
Bryan, woudn' t that make the entire line bold though? I only want "End Time: " in bold, not what "+GoEvent.Event_Time_End__c+" outputs.
Bryan JamesBryan James
you could use an apex:outputtext and the escape attribute set to false
<apex:outputText value="{! IF( ISBLANK(Contact.Owner.Email), '', "<b>End Time:</b> "+Contact.Owner.Email+"" ) }" escape="false"/>
This was selected as the best answer