blob: 6c244c90255077ef35adf84ab5f12d12f327a305 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
__setupPackage__(__extension__);
svg.templateHooks = {};
svg.regexpQuote = function (str, delimiter) {
return String(str).replace(
new RegExp(
'[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]',
'g'
),
'\\$&'
);
}
svg.getHooksPattern = function(){
var hookNames = [],
that = this;
for( var i in this.templateHooks )
hookNames.push(i);
// hook_name( arg1 [, arg2]... )
if( hookNames.length ){
var pattern = "("+hookNames.join('|')+")\\(([^\\(\\)]+)\\)\\s*;?";
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
// console.log(pattern);
return pattern;
}
}
global = this;
svg.templateHooks.variable = function( varName ){
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
// console.log(global[varName]);
if( varName in global ){
return global[varName];
}
return '';
}
svg.templateHooks.prop = function( propName, varName ){
var out = '';
if( (varName in global) ){
var value = global[varName];
if( isNumber(value) ){
out = propName + ':' + value + ';';
} else if( value.length ) {
out = propName + ':' + value + ';';
}
} else {
print( 'Unable to find ' + varName + ' for prop hook.' );
}
// print( varName + ' => ' out + ' | ' + (varName in global) );
return out;
}
|