-
-
Save JeromeDane/74c237dc9b98314cb4d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note the addition of if(matches) on line 8 below | |
replaceVars: function(value, props) | |
{ | |
if (!value || !props) return value; | |
var matches = value.match(/{.*?}/ig); | |
if(matches) { | |
for(var i = 0, leni = matches.length; i < leni; i++) | |
{ | |
var match = matches[i]; | |
var matchValues = match.split(/{|}/ig).join(""); | |
value = value.split(match).join(stroep.core.StringUtil.findPropValue(match, matchValues, props)); | |
}; | |
} | |
return value; | |
}, | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In reference to http://blog.stroep.nl/2012/07/javascript-template-system/.
You need to add a check to see if there are actually any {tag} patterns otherwise the template crashes when no tags are included.