Render code if condition is true

conditionalifrendered

I want to render the span syntax only if the wrapper.AccHead is not empty.
I tried the code below, but it does'nt work.
I tried also to use the rendered syntax in span but it does' nt work.

Is there a way to use something like that?

   <span rendered="{!IF(wrapper.AccHead = '', false,true)}" class="slds-icon_container" style="background-color: #FF934F;">
      <svg aria-hidden="true" class="slds-icon slds-icon--x-small">                             
         <use xlink:href="{!URLFOR($Asset.SLDS, 'assets/icons/standard-sprite/svg/symbols.svg#hierarchy')}" />
      </svg>
   </span>



{!IF(wrapper.AccHead = '', false,
   <span class="slds-icon_container" style="background-color: #FF934F;">
      <svg aria-hidden="true" class="slds-icon slds-icon--x-small">                             
         <use xlink:href="{!URLFOR($Asset.SLDS, 'assets/icons/standard-sprite/svg/symbols.svg#hierarchy')}" />
      </svg>
   </span>
}

Best Answer

You need to use a Visualforce element, typically apex:outputText, to render a section dynamically:

 <apex:outputText rendered="{!IF(wrapper.AccHead != '')}" 
   <span class="slds-icon_container" style="background-color: #FF934F;">
      <svg aria-hidden="true" class="slds-icon slds-icon--x-small">                             
         <use xlink:href="{!URLFOR($Asset.SLDS, 'assets/icons/standard-sprite/svg/symbols.svg#hierarchy')}" />
      </svg>
   </span>
 </apex:outputText>
Related Topic