raintpl3
raintpl3 copied to clipboard
Set variable error
Hello. I'm trying to upgrade my project to use Composer, and updated from RainTPL 2.7 to 3.1.
I had a line in my HTML Template:
{$requirejs_main='//cdn.my-project.com/assets/js/jquery.js'}
When RainTPL renders it I get
<?php $requirejs_main='//cdn["my"]-project["com"]/assets/js/jquery["js"]'; ?>
and that is not what I expect it to be.
Although //cdn.my-project.com/assets/js/jquery.js
is not the real URL, but the concept is the same. I suppose some "magic" is done before rendering variable value, finally causing the issue. Any way to avoid this weird situation?
Hi Alexander,
this is definitely an issue and I'm sorry about that, ideally RainTPL inside quote or double quote shouldn't run any replacement, I'll work on it as soon as I have a chance but meanwhile you can do this workaround: {$requirejs_main='//cdn.' . 'my-project.' . 'com/assets/js/jquery.' . 'js http://cdn.my-project.com/assets/js/jquery.js'}
I'll update this post as soon I or someone else will implement a solution for it.
Thanks.
On Fri, Dec 19, 2014 at 6:37 AM, Alexander Pyatkin <[email protected]
wrote:
Hello. I'm trying to upgrade my project to use Composer, and updated from RainTPL 2.7 to 3.1. I had a line in my HTML Template: {$requirejs_main='//cdn.my-project.com/assets/js/jquery.js'}
When RainTPL renders it I get
and that is not what I expect it to be.Although //cdn.my-project.com/assets/js/jquery.js is not the real URL, but the concept is the same. I suppose some "magic" is done before rendering variable value, finally causing the issue. Any way to avoid this weird situation?
— Reply to this email directly or view it on GitHub https://github.com/rainphp/raintpl3/issues/165.
I found a simpler workaround
{$url= 'http://www.example.com'}
Just add extra space after equal sign
Oh snap, yeah I forgot about that trick. Thanks!
On Tue, Dec 23, 2014 at 2:34 AM, Alexander Pyatkin <[email protected]
wrote:
I found a simpler workaround {$url= 'http://www.example.com'} Just add extra space after equal sign
— Reply to this email directly or view it on GitHub https://github.com/rainphp/raintpl3/issues/165#issuecomment-67927887.
https://github.com/rainphp/raintpl/issues/30
it is fixed in RTPL2. Maybe add the same fix here?
There is a bug in varReplace() function. I will rewrite it to fix this bug and correctly parse strings and other non-variables.