summaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authorJean Claveau <jean.claveau@c277.fr>2014-10-05 17:39:48 +0200
committerJean Claveau <jean.claveau@c277.fr>2014-10-05 17:39:48 +0200
commit33612cdcc1ab5f3e73e7647a8e62ecbab1495432 (patch)
tree7c1207bbcf2d31e77c1e0db24d2e71a4875e1294 /script
parent9b4cb41446c7e769795fcf0147241cac6f103d12 (diff)
moving hook pattern definition to script extension
Diffstat (limited to 'script')
-rw-r--r--script/svg/__init__.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/script/svg/__init__.js b/script/svg/__init__.js
index 16811a2b06..6c244c9025 100644
--- a/script/svg/__init__.js
+++ b/script/svg/__init__.js
@@ -12,23 +12,24 @@ svg.regexpQuote = function (str, delimiter) {
);
}
-svg.hookNames = function(){
- var hookNames = ['variable'],
+svg.getHooksPattern = function(){
+ var hookNames = [],
that = this;
for( var i in this.templateHooks )
hookNames.push(i);
- hookNames.toPattern = function(){
- for( var i in this )
- this[i] = that.regexpQuote(this[i]);
- return this.join('|');
+ // hook_name( arg1 [, arg2]... )
+ if( hookNames.length ){
+ var pattern = "("+hookNames.join('|')+")\\(([^\\(\\)]+)\\)\\s*;?";
+
+ // console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
+ // console.log(pattern);
+ return pattern;
}
-
- return hookNames;
}
global = this;
-svg.templateHooks.variable = variable = function( varName ){
+svg.templateHooks.variable = function( varName ){
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
// console.log(global[varName]);
if( varName in global ){
@@ -37,7 +38,7 @@ svg.templateHooks.variable = variable = function( varName ){
return '';
}
-svg.templateHooks.prop = prop = function( propName, varName ){
+svg.templateHooks.prop = function( propName, varName ){
var out = '';
if( (varName in global) ){
@@ -50,7 +51,7 @@ svg.templateHooks.prop = prop = function( propName, varName ){
}
} else {
- // print( 'Unable to find ' + varName + ' for prop hook.' );
+ print( 'Unable to find ' + varName + ' for prop hook.' );
}
// print( varName + ' => ' out + ' | ' + (varName in global) );