laravel 刀片引擎:打印三重花括号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29621970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:21:08  来源:igfitidea点击:

Blade engine: print triple curly braces

laravelblade

提问by Tim

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

我知道如何在 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.

但是我怎样才能打印三重花括号呢?我在之前添加 @ 的第一个想法不起作用,Laravel 仍然尝试解释它。

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

有没有一种简单的方法而不将大括号编码为 HTML 实体?

采纳答案by Faiz

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

这是最简单的方法。使用 HTML 实体来转义花括号。在 Laravel 5 中测试。请参阅此处的 HTML 实体列表。HTML 实体

Code

代码

{{{text}}}

Output

输出

{{{text}}}

回答by lukasgeiter

Update

更新

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

最近,合并了一个拉取请求来解决这个问题!!
Laravel 5.1.7 开始,可以@按预期使用该符号:

@{{{ ... }}}


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

如果我发现更好的东西,我会进一步调查并更新这个答案......

回答by Hamid Mohayeji

Use this if you just want to print them:

如果您只想打印它们,请使用它:

{{ '{{{' }}

回答by LyleK

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:

我在 Laravel 4.2 中尝试使用 Vue.js 渲染一些原始 HTML 时遇到了同样的问题。对我来说,最简单的解决方案是在刀片模板中使用一个简单的 php echo 语句:

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

Did the trick for me.

对我有用。

回答by umar_

One more way is as following

另一种方法如下

{@{{Text}}}