@@ -26,87 +26,6 @@ d3.selection.prototype.appendSVG = function(_svgString) {
26
26
return d3 . select ( this . node ( ) . lastChild ) ;
27
27
} ;
28
28
29
- // Complex templating
30
- // @see https://github.com/jashkenas/underscore/blob/master/underscore.js#L1234
31
- /////////////////////////////
32
- util . tmpl = function ( text , data ) {
33
- var settings = {
34
- evaluate : / < % ( [ \s \S ] + ?) % > / g,
35
- interpolate : / < % = ( [ \s \S ] + ?) % > / g,
36
- escape : / < % - ( [ \s \S ] + ?) % > / g
37
- } ;
38
-
39
- var escaper = / \\ | ' | \r | \n | \u2028 | \u2029 / g;
40
-
41
- var escapes = {
42
- '\'' : '\'' ,
43
- '\\' : '\\' ,
44
- '\r' : 'r' ,
45
- '\n' : 'n' ,
46
- '\u2028' : 'u2028' ,
47
- '\u2029' : 'u2029'
48
- } ;
49
-
50
- var escapeChar = function ( match ) {
51
- return '\\' + escapes [ match ] ;
52
- } ;
53
-
54
- // Combine delimiters into one regular expression via alternation.
55
- var noMatch = / ( .) ^ / ;
56
- var matcher = new RegExp ( [
57
- ( settings . escape || noMatch ) . source ,
58
- ( settings . interpolate || noMatch ) . source ,
59
- ( settings . evaluate || noMatch ) . source
60
- ] . join ( '|' ) + '|$' , 'g' ) ;
61
-
62
- // Compile the template source, escaping string literals appropriately.
63
- var index = 0 ;
64
- var source = '__p+=\'' ;
65
- text . replace ( matcher , function ( match , escape , interpolate , evaluate , offset ) {
66
- source += text . slice ( index , offset ) . replace ( escaper , escapeChar ) ;
67
- index = offset + match . length ;
68
-
69
- if ( escape ) {
70
- source += '\'+\n((__t=(' + escape + '))==null?\'\':_.escape(__t))+\n\'' ;
71
- } else if ( interpolate ) {
72
- source += '\'+\n((__t=(' + interpolate + '))==null?\'\':__t)+\n\'' ;
73
- } else if ( evaluate ) {
74
- source += '\';\n' + evaluate + '\n__p+=\'' ;
75
- }
76
-
77
- // Adobe VMs need the match returned to produce the correct offest.
78
- return match ;
79
- } ) ;
80
- source += '\';\n' ;
81
-
82
- // If a variable is not specified, place data values in local scope.
83
- if ( ! settings . variable ) source = 'with(obj||{}){\n' + source + '}\n' ;
84
-
85
- source = 'var __t,__p=\'\',__j=Array.prototype.join,' +
86
- 'print=function(){__p+=__j.call(arguments,\'\');};\n' +
87
- source + 'return __p;\n' ;
88
-
89
- var render ;
90
- try {
91
- render = new Function ( settings . variable || 'obj' , '_' , source ) ;
92
- } catch ( e ) {
93
- e . source = source ;
94
- throw e ;
95
- }
96
-
97
- if ( data ) return render ( data ) ;
98
- var template = function ( data ) {
99
- return render . call ( this , data ) ;
100
- } ;
101
-
102
- // Provide the compiled source as a convenience for precompilation.
103
- var argument = settings . variable || 'obj' ;
104
- template . source = 'function(' + argument + '){\n' + source + '}' ;
105
-
106
- return template ;
107
- } ;
108
-
109
-
110
29
// Text utilities
111
30
/////////////////////////////
112
31
0 commit comments