diff --git a/v3/pwiki/parser.js b/v3/pwiki/parser.js
index 8fff0e5..e5642b4 100644
--- a/v3/pwiki/parser.js
+++ b/v3/pwiki/parser.js
@@ -1244,6 +1244,8 @@ module.parser = {
function(st){
return ((st ?? state).slots ?? {})[name] },
{slot: name}) }) })),
+ // XXX do not like this name...
+ content: ['slot'],
//
@@ -1566,6 +1568,7 @@ module.parser = {
// set macro...
if(name && body){
;(state.macros ??= {})[name] = body
+
// get macro...
} else if(name){
body = (state.macros ?? {})[name] }
@@ -1573,10 +1576,18 @@ module.parser = {
// else...
if(args.src
&& !page.get(args.src).exists()){
+ // ..
for(var elem of body){
if(elem.name == 'else'){
body = elem.body
- return that.expand(page.get(args.src), elem.body, state) } } }
+ return that.expand(page.get(args.src), body, state) } }
+ // args.else...
+ return args['else'] ?
+ that.expand(page.get(args.src), args['else'], state)
+ : [] }
+
+ // join macro???
+ // XXX
return args.src && body ?
// run macro...
@@ -1584,12 +1595,9 @@ module.parser = {
function(page, body, path, text, state){
return this.expand(page.get(path), body, state) })
: '' }) })),
-
// nesting rules...
'else': ['macro'],
join: ['macro'],
- // XXX do not like this name...
- content: ['slot', 'include', 'quote', 'macro'],
},
}
diff --git a/v3/pwiki/test/parser.js b/v3/pwiki/test/parser.js
index 16106c8..739a5b1 100755
--- a/v3/pwiki/test/parser.js
+++ b/v3/pwiki/test/parser.js
@@ -53,6 +53,7 @@ module.exports.P = {
get basepath(){
return path.dirname(this.path ?? '') },
+ // XXX should this return current path if it does not exixt???
get matched(){
var path_action_pattern = /\/path\/?/
var path = this.path.replace(path_action_pattern, '')
@@ -74,6 +75,7 @@ module.exports.P = {
:p]
: [] })
.flat() }
+ // XXX should this return current path if it does not exixt???
return [this.path] },
exists: function(path){
var that = this
@@ -330,8 +332,21 @@ test.Setups({
// for inline quoting see: test.Modifiers.quote
// XXX
- // XXX macro...
- // XXX
+ // macro...
+ macro: function(assert, path='/page', res){
+ return {
+ page: P,
+ code: [
+ '[[ @source(./path) ]]',
+ res ?? ('[[ '+ path +' ]]'), ], } },
+ macro_404: function(assert){
+ return this.macro(assert, '/not_found', '') },
+ macro_else: function(assert){
+ return {
+ page: P,
+ code: [
+ '[[ @source(./path) ]]ERR',
+ 'ERR', ], } },
// XXX var...
// XXX