Hi Charly - you are quite right in your expectations for this function -
the issue had been previously noted in this IRC chat from earlier this
month:
http://wiki.fluidproject.org/display/fluid/fluid-work+IRC+Logs-2011-06-01
As the transcript shows, one jhung had been actioned as producing a JIRA
for this issue - which I do invite him or anyone else to do :) I would
do it myself but I am on holiday this week -
More soon,
Cheers,
Antranig
On 17/06/2011 00:27, charly molter wrote:
Hello,
I'm currently using the stringTemplate function on a template like
that "<%tag %classes %attributes>%content</%tag>" my problem is
that it doesn't do the multiple replacement of %tag after checking the
code:
fluid.stringTemplate = function (template, values) {
var newString = template;
for (var key in values) {
var searchStr = "%" + key;
newString = newString.replace(searchStr, values[key]);
}
return newString;
};
It seems quite obvious that it doesn't do it. However I think this is
a lack, you expect from this kind of function to replace every
occurrences of a similar token.
So please tell me if there's something I've missed to use it that way...
Otherwise after looking for a little bit I've found that enhancement
that would enable to do that:
fluid.stringTemplate = function (template, values) {
var newString;
var tmpString = template;
for (var key in values) {
var searchStr = "%" + key;
do {
newString = tmpString;
tmpString = newString.replace(searchStr, values[key]);
} while(tmpString !== newString);
}
return newString;
};
So what do you think about it? Am I the only one thinking that the
replacement in a template should be repetitive?
_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://fluidproject.org/mailman/listinfo/fluid-work