raintpl3 icon indicating copy to clipboard operation
raintpl3 copied to clipboard

Set variable error

Open aspyatkin opened this issue 10 years ago • 5 comments

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?

aspyatkin avatar Dec 19 '14 11:12 aspyatkin

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.

feulf avatar Dec 22 '14 03:12 feulf

I found a simpler workaround {$url= 'http://www.example.com'} Just add extra space after equal sign

aspyatkin avatar Dec 23 '14 07:12 aspyatkin

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.

feulf avatar Dec 23 '14 19:12 feulf

https://github.com/rainphp/raintpl/issues/30

it is fixed in RTPL2. Maybe add the same fix here?

Xesau avatar Jan 16 '15 20:01 Xesau

There is a bug in varReplace() function. I will rewrite it to fix this bug and correctly parse strings and other non-variables.

keskad avatar Mar 13 '15 18:03 keskad