XF 2.1 No wrapper BB code and condition for an empty option

Hello, everybody.
An interesting question has come up. Nobody worked out the solutions below?

1. There is bb code [span class="{option}"]{text}[/span]
option is an optional parameter.
what need:
  • if option != 0, the output <span class="option">text</span>
  • if option = 0, the output of <span>text</span> (now <span class="">text</span> is incorrect)
that is need a construction like <span {if ($option!=0) echo'class="option";}>text</span>
2. It's need to be able to create non-wrap bb codes, like a smiley face or an emoticon: [:)] for bb code [hr].
Last edited: