You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							22 lines
						
					
					
						
							656 B
						
					
					
				
			
		
		
	
	
							22 lines
						
					
					
						
							656 B
						
					
					
				define(['./keys'], function (keys) {
 | 
						|
 | 
						|
  // Internal helper to generate functions for escaping and unescaping strings
 | 
						|
  // to/from HTML interpolation.
 | 
						|
  function createEscaper(map) {
 | 
						|
    var escaper = function(match) {
 | 
						|
      return map[match];
 | 
						|
    };
 | 
						|
    // Regexes for identifying a key that needs to be escaped.
 | 
						|
    var source = '(?:' + keys(map).join('|') + ')';
 | 
						|
    var testRegexp = RegExp(source);
 | 
						|
    var replaceRegexp = RegExp(source, 'g');
 | 
						|
    return function(string) {
 | 
						|
      string = string == null ? '' : '' + string;
 | 
						|
      return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
 | 
						|
    };
 | 
						|
  }
 | 
						|
 | 
						|
  return createEscaper;
 | 
						|
 | 
						|
});
 |