Comments (7)
@JustBlackBird I can't get my head around this. I need to generate exactly one \
before a variable.
handlebars.js use two \\
to output a \
but since its PHP, the the \\
in any case compiled to \
(before loading by engine, I can't understand why PHP translate '\\'
to \
even when I am in single qute!)
So if i want exactly two, I should have \\\
OR \\\\
(WTF?) so this are wrong
https://github.com/XaminProject/handlebars.php/blob/master/tests/Xamin/HandlebarsTest.php#L130
Any idea on this?
from handlebars.php.
@fzerorubigd, according to php manual \\\{
inside of single quotes is equal to \\\\{
, thus this and this test cases do the same job.
To get a single backslash inside a PHP's string one should double it. So
$s = "\\{{var}}";
puts \{{var}}
string into $s
variable and
$s = "\\\\{{var}}";
puts \\{var}
.
The problem is the current Handlebars.php parser does not replace \\
in a template with \
. You can check this behavior by using templates with \Handlebars\Loader\FilesystemLoader
:
will be rendered to \{{var}}
while
becomes \\value
but should be rendered to \value
.
To summarize, you are right, there is no way to render \\{{var}}
template correctly.
from handlebars.php.
A workaround would be to store a single backslash in a different variable and then use
{{backslash}}{{var}}
inside the template.
from handlebars.php.
@majortom731 it's a dirty hack. The problem should be fixed in the Core.
from handlebars.php.
@majortom731 Actually, I use that in my template right now. but as @JustBlackBird said we need to fix it in core.
from handlebars.php.
Here is a jsfiddle that illustrates Handlebars.js behavior: http://jsfiddle.net/cLxyge73/1/ . It seems that only slashes before opening curly brace ({
) should be doubled.
from handlebars.php.
@fzerorubigd could you please review #118 ?
from handlebars.php.
Related Issues (20)
- Get current helper content as string or tree HOT 4
- How to use @last in #each HOT 1
- A way to use arbitrary text as arguments in custom helper HOT 3
- Redundant newlines HOT 10
- Variables are searched only in current context not in context stack HOT 1
- How to test if helper was used as block or non block? HOT 2
- Helper that have another helper inside that modify its behavior HOT 5
- Helper try to execute another helper even that it's inside quotes HOT 1
- Registering MANY Partials at once HOT 1
- When-helper nested in each loop: clears variables? HOT 3
- Mustache-style Context Lookups HOT 1
- Could you make a release tag? HOT 2
- How can I use this JS template in a page rendered by handlebars.php HOT 2
- what does it means "\.?" in the end of variable $variable_name
- includeZero doesn't seem to work. HOT 1
- How to use #invoke recursively inside #define helper? HOT 2
- Using Dynamic Partial Names HOT 6
- Can't seem to get parent @key in nested #each to work: {{@../key}} HOT 1
- PHP 7.3 error HOT 1
- LogHelper
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from handlebars.php.