Blade engine: print triple curly braces - laravel

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?

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

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

Use this if you just want to print them:
{{ '{{{' }}

One more way is as following
{#{{Text}}}

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.

Related

Laravel safe way to output text with line breaks

When I insert data I dont sanetize the text in any way, I just do small things suck as making the first leter capital and striping linebreaks when there are more than two in a row.
So if I now output the text using:
{{ $text }}
I am safe since this way laravel strips any dangerous data/tags to prevent xss. But the problem now is that I dont have any linebreaks in the text.
So now I tried this:
{!! nl2br(e($text))!!}
This seems to work, I keep my linebreaks and things like <script>alert('xss');</script> gets output as normal text. But is this the proper way to output text safe in laravel while keeping linebreaks?
Yes, that's the correct way to achieve this.
{{ $text }} is equivalent to {!! e($text) !!}.

How to Use Nested Curly Braces in Laravel 5

Hi everyone I am trying to use curly braces like this
Edit
Output:
http://localhost/projects/2/edit
but actual output should come like this
http://localhost/scrumwala/public/projects/2/edit
How i Can get my project url like this please suggest.

Escape single quote in Xtend template expression

I have a very simple question, but could not figure it out by Google search, please help.
I want to produce this string '\u0000' (note the simple quote marks surrounding it!) using the following simple Xtend method containing a template expression:
def String makeDefaultChar()
{
''''\u0000''''
}
However, this is not accepted as proper syntax (probably because of the four ''''. Is there an escape character for this use case or what is the right syntax?
Thank you in advance!
P.S.
Of course I could use plain Java string like this "'\\u0000'" to achieve the same, but I want to use an Xtend template expression.
My Xtend version is: 2.9.1.v201512180746
There is no "escaping" in template expressions, so you have to use the workaround you mentioned:
'''«"'\\u0000'"»'''
or
'''«"'"»\u0000«"'"»'''
Related discussion: https://groups.google.com/forum/#!topic/xtend-lang/bVZ0nKmQGAI
Single quotes are allowed within Xtend templates as long as they do not occur at the beginning or the end of the template. So a simple workaround is to add an empty expression before/after the single quote:
'''«»'\u0000'«»'''

Ignore MediaWiki whitespace

How do I ignore whitespace on a wiki template?
So for example, I create a template called Hello. Inside that, I put {{{text}}}.
So now when I put {{Hello |text=Hi Bye}} on a page, and save it, the page says. "Hi Bye" (of course).
I want it to display "HiBye", not "Hi Bye". What do I put in the template to do that?
To remove characters inside the value in a template (whitespace or other), you have to search and replace. You can install the extensions ParserFunctions, to get access to parser functions like replace, and then to something like this:
{{#replace:{{{text|}}}| |}}
If your MediaWiki is version 1.18 or newer (if it's not, you should upgrade anyway), ParserFunctions is already bundled with your installation. Then you just have to enable it, like this in LocalSettings.php:
require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
$wgPFEnableStringFunctions = true;
On a side note, whitespace characters in the beginning and end of a variable is always stripped, if using named parameters. In other words: {{Hello |text= Hi Bye }} is equal to {{Hello |text=Hi Bye}}. On the other hand, {{Hello | Hi Bye }} is not equal to {{Hello |Hi Bye}}. Advanced templates sometimes make clever use of this difference. The replace function will work in both cases, of course.

Smarty Remove Everything after specific character

I have this:
{$videos[i].videofile}
and my $videos[i].videofile equals to 12931024123.mp4
I want to remove everything after the dot. I have already tried |strstr:'.':true, but it does not work (wrong parameters count).
NO PHP NEEDED. Must be done with Smarty functions in the template.
Not really the cleanest solution but you asked specifically for it: you could simply use PHPs substr as a modifier:
{$videos[i].videofile|substr:0:-4}
This will return 12931024123

Resources