framework: Laravel won't print double curly brackets from the template or from Controller if I render a view after trying to print
- Laravel Version: 5.3.6
- PHP Version: 7.0.8
- Database Driver & Version: MySql
Description:
I am building a blog where I can enter php, html and javascript code, even blade template code. I found that Laravel won’t print double curly brackets like these {{ }} from the blade template. or the Controller if I render the template after printing.
So to test if was php causing trouble and not printing curly brackets I did this in my Controller:
echo 'test {{ test }}';
dd();
and test {{ test }} got printed. I then removed the dd(); so the code now looked like this:
echo 'test {{ test }}';
$post = Post::where('id', $id)->first();
return view('admin.posts.edit')->withPost($post);
Now only ‘test test’ got printed without curly bracekts. I then commented out
//return view('admin.posts.edit')->withPost($post);
and now test {{ test }} got printed again.
It’s obvious that Laravel is preventing me from printing curly brackets and is removing them. I need to be able to print them from the blade template. Why isn’t it working and how to solve this?
Steps To Reproduce:
inside a function in Controller do this
echo 'test {{ test }}';
return view('someview');
only ‘test test’ will be printed, remove the return view and test {{ test }} gets printed
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (5 by maintainers)
You need to escape them, with an
@
.I know this is an old thread and not sure this is exactly the issue, but yesterday I discovered you can skip elements from being compiled with Vue using
v-pre
.<span v-pre>{{ this will not be compiled }}</span>
https://vuejs.org/v2/api/#v-pre
@VisualTrauma The problem is not exactly like that: Controller:
return view('someview', ['test_variable' => 'test {{ test }}'])
someview.blade.php:{{ $test_variable }}
Displaytest test
Laravel 5.3 To displaytest {{ test }}
I have to comment out app.jsIs this still an issue? I tried copying
echo 'test {{ test }}'; return view('someview');
first run it prints test {{test}}. second run (without return view) it still prints test {{test}}. I haven’t changed anything in my Laravel project, lot of things added though.Try removing Vue.js …
The {{ content }} is printed in the source code. When I remove the shipped app.js the {{ content }} is visible.