Blade engine: print triple curly braces

流过昼夜 提交于 2019-11-27 06:42:28

问题


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?


回答1:


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



回答2:


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




回答3:


Use this if you just want to print them:

{{ '{{{' }}



回答4:


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.




回答5:


One more way is as following

{@{{Text}}}


来源:https://stackoverflow.com/questions/29621970/blade-engine-print-triple-curly-braces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!