XF 2.0 Show code(bbcode) on pages

Russ

Well-known member
I haven't really tried this before but... is there any way of using the Code BBCode on a normal page?

I have this:
Code:
<xf:include template="bb_code_tag_code">
    <xf:set var="$content"><span>this is code<b>should show with the html tags</b></span></xf:set>
</xf:include>

But it outputs as:
Screenshot_8.webp

Rather than the desired output:
Code:
<span>this is code<b>should show with the html tags</b></span>

I can just use XMP tags for my purpose but I'm just curious if there's a solution to the above.
 
You can wrap the string in [code] tags and use the bb_code() function:
HTML:
{{ bb_code("[code]<span>this is code<b>should show with the html tags</b></span>[/code]", null, null) }}

Or you can escape the HTML when setting the variable using the escape filter:
HTML:
<xf:include template="bb_code_tag_code">
    <xf:set var="$content">{{ "<span>this is code<b>should show with the html tags</b></span>"|escape }}</xf:set>
</xf:include>

Or if you use the self-closing form of <xf:set>, the value will be escaped automatically:
HTML:
<xf:include template="bb_code_tag_code">
    <xf:set var="$content" value="<span>this is code<b>should show with the html tags</b></span>" />
</xf:include>
 
Back
Top Bottom