Home » Php » Blade engine: print triple curly braces

Blade engine: print triple curly braces

Posted by: admin November 29, 2017 Leave a comment

Questions:

I know how to print double curly braces in Laravel: @{{ }}.

But how can I print triple curly braces? My first thought of adding an @ before does not work, Laravel still tries to interpret it.

Is there an easy way without encoding the braces to HTML entities?

Answers:

This is the easiest way. Use HTML entities to escape curly braces. Tested in Laravel 5.
See here for the list of HTML entities. HTML Entities

Code

{{ '{{{' . 'text'. '}}}' }}

Output

{{{text}}}

Questions:
Answers:

Update

Very recently, a pull request was merged that fixes this problem!!
As of Laravel 5.1.7 it is possible to use the @ sign as expected:

@{{{ ... }}}

Original Answer

The least ugly workaround I found up until now is to escape the first two brackets as normal and adding an invisible between them and the third bracket:

@{{‌{test}}}

I’ll investigate further and update this answer if I find something better…

Questions:
Answers:

Use this if you just want to print them:

{{ '{{{' }}

Questions:
Answers:

I ran into the same issue trying to render some raw HTML using Vue.js in laravel 4.2. For me the easiest solution was to just to use a simple php echo statement in the blade template:

<?php echo '{{{ text }}}'; ?>

Did the trick for me.