Escaping Data in Laravel Blade Files

Chris Sevilleja
💬 comments


t's always good practice to escape data when displaying it to our users. This is very simple to do in Laravel since they provide great tools to display data.

Normally, you can use the double curly braces ({{ $variable }}) to display data. However, this does not escape data.

Don't worry though, Laravel provides a very easy way to do this without changing your code drastically. Introducing the triple curly brace!

Table of Contents

    Escaping Data with 3 Curly Braces

    // escaped 
    {{{ $variable }}}
    // not escaped
    {{ $variable }}

    Just like that, we have an application/site that is that much safer.

    Chris Sevilleja

    173 posts

    Founder of Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.