You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2012/01/11 16:18:13 UTC
svn commit: r1230085 -
/incubator/wookie/trunk/widgets/templates/browse/scripts/browse_controller.js
Author: scottbw
Date: Wed Jan 11 15:18:13 2012
New Revision: 1230085
URL: http://svn.apache.org/viewvc?rev=1230085&view=rev
Log:
Use regex to find and replace all occurrences of a token in an item detail template when transforming data into HTML in the Browse template. (JavaScript replace by substring only uses the first match).
Modified:
incubator/wookie/trunk/widgets/templates/browse/scripts/browse_controller.js
Modified: incubator/wookie/trunk/widgets/templates/browse/scripts/browse_controller.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/browse/scripts/browse_controller.js?rev=1230085&r1=1230084&r2=1230085&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/browse/scripts/browse_controller.js (original)
+++ incubator/wookie/trunk/widgets/templates/browse/scripts/browse_controller.js Wed Jan 11 15:18:13 2012
@@ -162,12 +162,14 @@ ${widget.shortname}_browse_controller.tr
var elements = ${browse.item.elements}.split(",");
for (var i=0;i<elements.length;i++){
var element = elements[i];
- item = item.replace("${"+element.toUpperCase()+"}", $(this).find(element).text());
+ var pattern = "\\$\{" + element.toUpperCase() +"\}";
+ item = item.replace(new RegExp(pattern,'g'), $(this).find(element).first().text());
}
var attributes = ${browse.item.attributes}.split(",");
for (var i=0;i<attributes.length;i++){
var attribute = attributes[i];
- item = item.replace("${"+attribute.toUpperCase()+"}", $(this).attr(attribute));
+ var pattern = '\\$\{'+attribute.toUpperCase()+'\}';
+ item = item.replace(new RegExp(pattern,'g'), $(this).attr(attribute));
}
items += item;
}