tel8618217223380/jquery-utils

can not handle "{{" charactor correctly

Opened this issue · 0 comments

The following code will not work.
 $.format("{{guid: {0}}", 0)

What is the expected output? What do you see instead?
 return "{guid: 0}"

What version of the product are you using? On what operating system?
0.8.0

Please provide any additional information below.
The following code will generate the correct result:
        format: function(str, args) {
            var end = 0;
            var start = 0;
            var match = false;
            var buffer = [];
            var token = '';
            var tmp = (str || '').split('');
            for (start = 0; start < tmp.length; start++) {
                if (tmp[start] == '{') {
                    if (tmp[start + 1] == '{') {
                        buffer.push('{');
                        start++;
                    }
                    else {
                        end = str.indexOf('}', start);
                        token = tmp.slice(start + 1, end).join('');
                        buffer.push(strings.strConversion.__formatToken(token, (typeof arguments[1] != 'object') ? arguments2Array(arguments, 2) : args || []));
                    }
                }
                else if (start > end || buffer.length < 1) { buffer.push(tmp[start]); }
            }
            return (buffer.length > 1) ? buffer.join('') : buffer[0];
        },

Original issue reported on code.google.com by derek.li...@gmail.com on 9 Jun 2010 at 10:14