mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-30 10:30:08 +00:00
split the two macro stages....
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b3d5c857c8
commit
c69b5ab441
21
wiki.js
21
wiki.js
@ -506,6 +506,7 @@ var macro = {
|
|||||||
|
|
||||||
filter: {
|
filter: {
|
||||||
},
|
},
|
||||||
|
// macro stage 1...
|
||||||
macro: {
|
macro: {
|
||||||
// select filter to post-process text...
|
// select filter to post-process text...
|
||||||
filter_args: ['name'],
|
filter_args: ['name'],
|
||||||
@ -540,11 +541,25 @@ var macro = {
|
|||||||
|
|
||||||
} else if(name in slots){
|
} else if(name in slots){
|
||||||
slots[name] = text
|
slots[name] = text
|
||||||
// XXX on stage 2 need to return text
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// macro stage 2...
|
||||||
|
macro2: {
|
||||||
|
slot_args: ['name'],
|
||||||
|
slot: function(args, text, slots){
|
||||||
|
var name = args.name
|
||||||
|
|
||||||
|
if(slots[name] == null){
|
||||||
|
// XXX ???
|
||||||
|
return text
|
||||||
|
|
||||||
|
} else if(name in slots){
|
||||||
|
return slots[name]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
parseArgs: function(macro, args){
|
parseArgs: function(macro, args){
|
||||||
// XXX parse args and populate the dict via .*_args attr...
|
// XXX parse args and populate the dict via .*_args attr...
|
||||||
@ -568,8 +583,8 @@ var macro = {
|
|||||||
text = text.replace(this.__macro__pattern__, function(match, macro, args, text){
|
text = text.replace(this.__macro__pattern__, function(match, macro, args, text){
|
||||||
args = that.parseArgs(macro, args)
|
args = that.parseArgs(macro, args)
|
||||||
|
|
||||||
return macro in that.macro ?
|
return macro in that.macro2 ?
|
||||||
that.macro[macro].call(that, args, text, slots, filters)
|
that.macro2[macro].call(that, args, text, slots, filters)
|
||||||
: match
|
: match
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user