Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#7862 closed defect (worksforme)

_Templated.js bug: templates won't substitute value 0

Reported by: Les Owned by: Adam Peller
Priority: high Milestone: tbd
Component: Dijit Version: 1.2.0
Keywords: templated Cc:
Blocked By: Blocking:

Description

Please take a look at the line:

if(!value){ return ""; }

If value is 0, it won't be substituted. However, 1 (or a positive number) will substitute fine.

		_stringRepl: function(tmpl){
			var className = this.declaredClass, _this = this;
			// Cache contains a string because we need to do property replacement
			// do the property replacement
			return dojo.string.substitute(tmpl, this, function(value, key){
				if(key.charAt(0) == '!'){ value = _this[key.substr(1)]; }
				if(typeof value == "undefined"){ throw new Error(className+" template:"+key); } // a debugging aide
				if(!value){ return ""; }

				// Substitution keys beginning with ! will skip the transform step,
				// in case a user wishes to insert unescaped markup, e.g. ${!foo}
				return key.charAt(0) == "!" ? value :
					// Safer substitution, see heading "Attribute values" in
					// http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
					value.toString().replace(/"/g,"""); //TODO: add &amp? use encodeXML method?
			}, this);
		},

Change History (5)

comment:1 Changed 11 years ago by Adam Peller

Owner: set to Adam Peller

comment:2 Changed 11 years ago by Adam Peller

Looks like this was fixed in [15166]. Are you sure you're looking at the 1.2.0 release?

If you can still reproduce this problem on 1.2.0 please confirm and attach a test case.

comment:3 in reply to:  2 Changed 11 years ago by Les

Replying to peller:

Looks like this was fixed in [15166]. Are you sure you're looking at the 1.2.0 release?

I'm sorry I was using release 1.1.1

comment:4 Changed 11 years ago by Adam Peller

Resolution: worksforme
Status: newclosed

comment:5 Changed 11 years ago by Adam Peller

Milestone: 1.2.1tbd
Note: See TracTickets for help on using tickets.