Blade engine: print triple curly braces

前端 未结 5 2033
灰色年华
灰色年华 2020-12-11 01:25

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 wor

相关标签:
5条回答
  • 2020-12-11 01:45

    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...

    0 讨论(0)
  • 2020-12-11 01:47

    Use this if you just want to print them:

    {{ '{{{' }}
    
    0 讨论(0)
  • 2020-12-11 02:04

    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.

    0 讨论(0)
  • 2020-12-11 02:05

    One more way is as following

    {@{{Text}}}
    
    0 讨论(0)
  • 2020-12-11 02:06

    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

    &#123;&#123;&#123;text&#125;&#125;&#125;
    

    Output

    {{{text}}}
    
    0 讨论(0)
提交回复
热议问题