Open bernhardh opened 6 years ago
your Case 1 works if you add ->withShortcodes();
at the end.
Route::get('/test', function(){
return view('test')->with("code", '[b class="bold"]Bold text[/b]')->withShortcodes();
});
Result: https://prnt.sc/jyi07l
Thats not the problem, because case 1 is not expected to work, so its ok, that it doesn't work. The problem is the weird behavior of case 3.
test.blade.php
{{$code}}
<br>
{!! \Shortcode::compile($code) !!}
web.php
Route::get('/test', function(){
return view('test')->with("code", '[b class="bold"]Bold text[/b]');
});
Result: http://prntscr.com/jz3s82
Try using \Shortcode::enable();
in your controller or ->withShortcodes();
I think what @bernhardh wants to say is that he doesn't want the first line ({{ $code }}<br>
) to be parsed, while the second one should ({{ \Shortcode::compile($code) }}
).
This is also something we've been facing ourselves. Is there a way to achieve this?
Hello,
first of all: Thanks for your great work! I have the following issue (bug?):
I have the following controller:
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.
This is the result:
WTF? Why gets the first line (
{{ $code }}<br>
) parsed and why is the result wrong ("bold"
)?