Dwight Watson's blog

New Blade syntax in Laravel 5.0

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

It appears as there is going to be a new Blade syntax in the upcoming version of Laravel (was 4.3, but is now going to be 5.0 to be semi-semantic versioning). From now on, all content will be escaped by default. Previously double braces {{ and }} was just a standard echo while triple braces {{{ and }}} would escape the content.

Now, both double and triple braces will escape the content. This just makes it a lot harder for you to echo unescaped user content to the views which can be potentially dangerous. I've mentioned it a few times before, but the Laravel community hasn't often talked of this issue - even most Laracasts tutorials go without escaping content.

If you want to echo raw content in Laravel 5.0 (that is, not escaping it), your new syntax will be {!! and !!}. A little different.

Read more on the new syntax in the BladeCompiler.

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.