Skip to content

Selective usage of shortcode not working #34

Open
@bernhardh

Description

@bernhardh

Hello,

first of all: Thanks for your great work!
I have the following issue (bug?):

I have the following controller:

Route::get('shortcode', function(){
    return view('test.shortcode')->with("code", '[b class="bold"]Bold text[/b]');
});

Case 1 - As expected
When I use the variable $code in the template like:
{{ $code }}
it works as expected - I only get the raw string as a result:
[b class="bold"]Bold text[/b]

Case 2 - As expected
When I use the variable $code with the compile comand in the template like:
{{ \Shortcode::compile($code) }}
it works as well as expected - I get the (escaped) parsing result:
<strong class="bold">Bold text</strong>
Using it with unescaped blade:
{!! \Shortcode::compile($code) !!}
I get
<strong class="bold">Bold text</strong>

Case 3 - Weird
But when I combine both versions, the result is weird.

{{ $code }}<br>
{{ \Shortcode::compile($code) }}

This is the result:

<strong class="&quot;bold&quot;">Bold text</strong><br>
&lt;strong class=&quot;bold&quot;&gt;Bold text&lt;/strong&gt;

WTF? Why gets the first line ({{ $code }}<br>) parsed and why is the result wrong (&quot;bold&quot;)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions