function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fan YangFan Yang 

apex:component rendered in SPAN

Is it possible not to render apex:component in SPAN,  just let it rendered whatever I've coded

Best Answer chosen by Admin (Salesforce Developers) 
Alex_ConfigeroAlex_Configero

I don't think this is possible yet but is NEEDED! How can we develop HTML5 sites with all these unnecessary tags lingering around?

 

The only way around this is to close the span as soon as you open the component and then reopen it right before close, like this:

 

 

<apex:component >
</span>  <!-- necessary for clean markup - awaiting salesforce to fix this! -->
 <h2>CONTENT HERE</h2>
<span>  <!-- necessary for clean markup - awaiting salesforce to fix this! -->
</apex:component>

 Of course with the new API versions you can't even do that as the editor will complain that you have an unclosed component tag!!! So you need to change the version of the component to 15 or something like that.

 

I hope this helps and I hope the mods take note and relay this to the development team.

 

Alex Sartogo

Configero

 

All Answers

Ankit AroraAnkit Arora

You can use <apex:outputText> so that your code would not render as span for e.g.

 

where you use

 

 

<apex:outputPanel>
       Test
</apex:outputPanel>

It render as span.You can use

 

 

<apex:outputText>
       Test
</apex:outputText>

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 

 

Fan YangFan Yang

I need a re-usable component, not outputText or outputPanel. Thanks for your reply anyway.

Alex_ConfigeroAlex_Configero

I don't think this is possible yet but is NEEDED! How can we develop HTML5 sites with all these unnecessary tags lingering around?

 

The only way around this is to close the span as soon as you open the component and then reopen it right before close, like this:

 

 

<apex:component >
</span>  <!-- necessary for clean markup - awaiting salesforce to fix this! -->
 <h2>CONTENT HERE</h2>
<span>  <!-- necessary for clean markup - awaiting salesforce to fix this! -->
</apex:component>

 Of course with the new API versions you can't even do that as the editor will complain that you have an unclosed component tag!!! So you need to change the version of the component to 15 or something like that.

 

I hope this helps and I hope the mods take note and relay this to the development team.

 

Alex Sartogo

Configero

 

This was selected as the best answer
ca_peterson_oldca_peterson_old

I would think that this would break rerendering the component from the page it's used in, wouldn't it?

Alex_ConfigeroAlex_Configero

Nope. Works great as the tags end up being properly closed.

loneboatloneboat

You can use

<apex:outputText escape="false" value="<span>" />

to avoid having to reset your API version number.  The outputText doesn't know it's rendering HTML!  :-)

David NolderDavid Nolder
Old issue, but wanted to point out that as of API 12 you can add layout=none to the apex:component declaration...

<apex:component layout="none">
   ... your component stuff ...
</apex:component>