Dwoo - a PHP5 Template Engine

You are not logged in.

  • Index
  •  » Bug Reports
  •  » [Fixed] Problem with empty strings as a args to modifiers

#1 2008-06-11 11:46:03

BugTomek
Member
Registered: 2008-06-10

[Fixed] Problem with empty strings as a args to modifiers

Say I make use of 'replace' plugin to for example get rid of 'http://' from an url.
I would do that this way:

Code:

{$url|replace:'http://':''}

But this doesn't work as the compiler throws an exception saying that the 2nd argument is missing.

Also, I tried several other options that according to the docs probably should work (http://wiki.dwoo.org/index.php/Functions:replace).

Code:

{$url|replace:array('http://', b):array(a, b)}

produces "Argument 2/replace missing for replace"

Code:

{$url|replace:array('http://'):array(b)}

produces "Argument 2/replace missing for replace"

Code:

{$url|replace:'http://':array(b)}

the output is 'Arraywww.testurl.com'

Offline

 

#2 2008-06-11 11:52:45

Seldaek
Developer
Registered: 2008-03-24
Website

Re: [Fixed] Problem with empty strings as a args to modifiers

Thanks, I will look into those. Although to be honest, the |modifier syntax is not very well supported and quite complex to improve, so I would recommend calling those like {replace $url "http://" ""} and similar, I'm not saying it will fix everything in this case, but it might help.

Offline

 

#3 2008-06-11 13:37:55

Seldaek
Developer
Registered: 2008-03-24
Website

Re: [Fixed] Problem with empty strings as a args to modifiers

Alright, it's all fixed in SVN, with $url="http://test.com" they return :

test.com => OK
atest.com => OK
btest.com => OK

Notice:  Array to string conversion
Arraytest.com => OK given the fact your example was invalid, but parsing is fine.

FYI, the problem with the three last ones was that recursive calls (i.e. here you're calling array within a modifier call) didn't work with $var|modifier, only "string"|modifier, which is why my example in the documentation worked, anyway they both work now.
The first issue was a mistake in some regex, again applying only to modifiers on variables. It had .+ instead of .*, so it couldn't be empty.

Offline

 
  • Index
  •  » Bug Reports
  •  » [Fixed] Problem with empty strings as a args to modifiers

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson