Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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;
},
//...
@JeromeDane

This comment has been minimized.

Copy link
Owner Author

@JeromeDane JeromeDane commented Jan 4, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment