How to Use Nested Curly Braces in Laravel 5 - 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.

Related

preg_match(): Compilation failed: invalid range in character class

I'm a beginner for laravel an vuejs, when I am trying to refresh the page I got such error message, this is my code from web file :
Route::get('{path}',"HomeController#index")->where('path','(-a-z0-9_\s)');
Anyone with and idea?
From looking at you Regular Expression, even it it compiled you probably won't find any URI that matches it, so you will get Laravel No Route exception.
You should probably use Brackets [] to setup the range of character and add the + to match that range multiple times to make words or phrase. Use this Regex :
[-a-z0-9_\s]+
The Route codes :
Route::get('{path}',"HomeController#index")->where('path','[-a-z0-9_\s]+');
Or use Brackets inside the Parenthesis :
Route::get('{path}',"HomeController#index")->where('path','([-a-z0-9_\s]+)');
Use https://regex101.com/ to validate your string with Regex the next time
you just need to change your code like this
Route::get('{path}',"HomeController#index")->where('path','[-a-z0-9_\s]+');

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'«»'''

Blade engine: print triple curly braces

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.

smarty escape single quote in if else condition

need some help from smarty expert.
I am new in smarty template engine.
I would like to escape a single quote in a string, how can I do that
inside my .tpl
I got a if else condition
$current_category.category eq 'King's Tea'
the problem is the 'King's Tea' , that is my category name,
I tried 'King\'s Tea' , Smarty can't convert it
I tried {litereal}'King's Tea'{/litereal}, this one doesn't work in if else condition.
is there any way I can escape the single quote?
I tried to search in smarty API side. the escape page, just tell us how to escape from the variable.
$current_category.category eq "King's Tea"

Freemarker escaping freemarker

I'm using freemarker to generate a freemarker template. But I need some way to escape freemarker tags.
How would I escape a <#list> tag or a ${expression} ?
You could also use: ${"$"}{expression} if you find the {} nesting confusing.
I'm using the alternative syntax feature. I start the template with [#ftl] and use this syntax.
For the expressions I use the string literal feature: ${r"${expression}"}
You can configure FreeMarker to use [=exp] instead of ${exp} (since 2.3.28), and [#...]/[#...] instead of <#...>|<#...> by setting both the interpolation_syntax and the tag_syntax configuration setting to square_bracket (in the Java API: Configuration cfg; ... cfg.setInterpolationSyntax(Configuration.SQUARE_BRACKET_INTERPOLATION_SYNTAX) and cfg.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX)). Then the syntax doesn't clash with the default syntax.
There's one tricky case; if the template starts with <#ftl>, then it will switch the tag syntax back to angle_bracket. To counter that, just add a [#ftl] line before it.
See also: https://freemarker.apache.org/docs/dgui_misc_alternativesyntax.html
In the case when you want to use non-raw strings so that you can escape double quotes, apostrophes, etc, you can do the following:
Imagine that you want to use the string ${Hello}-"My friend's friend" inside of a string. You cannot do that with raw strings. What I have used that works is:
${"\x0024{Hello}-\"My friend's friend\""}
I have not escaped the apostrophe since I used double quotes.

Resources