s9e / TextFormatter

Text formatting library that supports BBCode, HTML and other markup via plugins. Handles emoticons, censors words, automatically embeds media and more.
MIT License
233 stars 36 forks source link

Optional attribute with xls:if #217

Closed Nearata closed 1 year ago

Nearata commented 1 year ago

hello!

my goal is to use this attribute internally to update the content the end-user will see.

# Configure.php

'[nearata-dsts login="{SIMPLETEXT1}" like="{SIMPLETEXT2}" reply="{SIMPLETEXT3}" error="{SIMPLETEXT4;optional}"]{ANYTHING}[/nearata-dsts]',
resolve(Factory::class)->make('nearata-dsts::bbcode')
# bbcode.blade.php

<div class="NearataDstsBBCode">
    <div class="title">{{ $translator->trans('nearata-dsts.forum.post.bbcode.hidden_content') }}</div>
    <div class="content">
        {ANYTHING}
    </div>
    {SIMPLETEXT4} // if i use @error it doesnt work
</div>

i tried

# bbcode.blade.php

...

// no working code
<xsl:if test="@error = ''">
    {ANYTHING}
</xsl:if>
<xsl:if test="@error != ''">
    {SIMPLETEXT4} // {@error} doesnt work
</xsl:if>

but it sounds like error doesnt exist in view

Illuminate \ View \ ViewException (E_ERROR)
syntax error, unexpected end of file, expecting "elseif" or "else" or "endif" (View: D:\GitHub Repositories\Nearata\flarum-ext-dsts\views\bbcode.blade.php)
Nearata commented 1 year ago

my bad, error is a variable in the view