Opened 13 years ago

Closed 13 years ago

#1863 closed defect (wontfix)

substituteParams using dojo.raise when should be using just return match

Reported by: joose Owned by: psowden
Priority: high Milestone:
Component: String Version: 0.4
Keywords: substituteParams Cc:
Blocked By: Blocking:

Description

Current substituteParams does not like when there are params that does not get substitutes. I think it should just return those as unchanged.

Attachments (2)

string-extras.patch (395 bytes) - added by joose 13 years ago.
Patch to fix substituteParams
string-extras.2.patch (979 bytes) - added by joose 13 years ago.
Patch to make it to work in strict (default) way or not (patched feature)

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by joose

Attachment: string-extras.patch added

Patch to fix substituteParams

Changed 13 years ago by joose

Attachment: string-extras.2.patch added

Patch to make it to work in strict (default) way or not (patched feature)

comment:1 Changed 13 years ago by bill

This is for the case where

var str="test %{foo} and %{bar}";
var str2=dojo.string.substituteParams(str, {"foo":"foo"});

Since the value of bar isn't specified you get an error. But I think that's a very unusual case where you want to do something like that, so I don't think it's worth adding a flag (although on the other hand I don't care what we do in that situation). If other people need this functionality then we'll consider adding it.

comment:2 Changed 13 years ago by Adam Peller

Resolution: wontfix
Status: newclosed

I did this deliberately, as I figured any time you have a substitution that doesn't match a param, it's almost certainly an error and the output is going to have silly %{} syntax that's not going to be what you intended. If we don't flag this by raising an exception, it's going to make it harder to detect these cases, and I think it will produce lesser quality code.

You're welcome to try to convince me otherwise :-)

Note: See TracTickets for help on using tickets.