Dwoo - a PHP5 Template Engine

You are not logged in.

#1 2008-06-29 12:41:56

temp
Member
Registered: 2008-06-16

[Fixed] wrong behaviour in {assign}

look at this:

Code:

{assign var="file" value="test.img"}
{assign var="path" value="/media/$file"}

this does not work, {$path} is "/media/".

otherhand this works:

Code:

{assign var="file" value="test.img"}
{assign var="path" value="/media/x$file"}

{$path} is now "/media/xtest.img".

maybe a problem with /$ ?

Offline

 

#2 2008-06-30 17:57:52

Seldaek
Developer
Registered: 2008-03-24
Website

Re: [Fixed] wrong behaviour in {assign}

This is because it assumes /$var means there is a division such as : $var/$var, so it doesn't parse it. I am not sure what to do with this honestly. It works if you do value="/media/`$file`" (as it delimits the variable).. But at the same time it sucks a bit having to do that, and I'm not sure it's worth it to allow such constructs in strings, since it is most likely to end up in a WTF than anything else.

Besides, should you really need the math, you could do value=cat("/media/" $file/$whatever), so yes I think I'll just remove it..

Offline

 

#3 2008-06-30 18:17:30

temp
Member
Registered: 2008-06-16

Re: [Fixed] wrong behaviour in {assign}

Hm - can't you just check for "" and do _no_ math in there? I mean math would be written as {assign value=12/$x} or am i wrong?
if i have a variable inside of a "" string that can't be math... hmm... sounds strange :-D

besides of that, i can live with the special quoting.

Offline

 

#4 2008-06-30 18:38:01

Seldaek
Developer
Registered: 2008-03-24
Website

Re: [Fixed] wrong behaviour in {assign}

Well I've just checked Smarty's doc about it, it is allowed in strings but only when the entire math is delimited with ``, so in your case it would work since you don't want math, and should you want it in a string (although I can't think of any really good reason but I'm sure someone would) you can using `$var/$var2` - sounds sane enough and I'd rather remain compatible with Smarty as much as possible, so I will try to rewrite the var parsing in strings to fix this, and meanwhile yes go for the `backticks`, it shouldn't break once I fix it so that's fine.

Offline

 

#5 2008-07-09 09:45:41

Seldaek
Developer
Registered: 2008-03-24
Website

Re: [Fixed] wrong behaviour in {assign}

Fixed in SVN, please confirm.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson