From 3829ce9764e4c6d4819e58a6aef28401b06909ce Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 28 Jun 2026 16:04:45 +0300 Subject: [PATCH] cleanup... Signed-off-by: Alex A. Naanou --- v3/pwiki/parser.js | 51 +++++------------------------------- v3/pwiki/test/parser.js | 57 +---------------------------------------- 2 files changed, 7 insertions(+), 101 deletions(-) diff --git a/v3/pwiki/parser.js b/v3/pwiki/parser.js index 9f794aa..ba08dc9 100644 --- a/v3/pwiki/parser.js +++ b/v3/pwiki/parser.js @@ -1287,9 +1287,10 @@ module.parser = { // are contained in, this will not lead to recursion. // // XXX do we actually need ?? - // - // - // + // + // + // + // nesting slots basically does the same thing... // XXX do we show a slot with unfilled content??? // ...what's the point in having , can't is just // be replaced by a slot? @@ -1321,43 +1322,6 @@ module.parser = { : name in slots) // set slot value... - /* XXX CONTENT... - var stack = [] - slots[name] - && stack.push(slots[name]) - delete slots[name] - text = text ? - parser.expand(this, text ?? [], state) - : text - if(body && text){ - stack.push(body) - var slot = text - } else { - var slot = body ?? text } - var original = slot - slots[name] - && stack.unshift(slot) - slot = slots[name] ??= slot - // handle ... - for(prev of stack.reverse()){ - // get the first - // NOTE: this is a flat search because we can't - // have indirect nesting (see: .group(..)) - for(var i in prev){ - if(typeof(prev[i]) != 'string' - && prev[i].name == 'content'){ - break } - i = null } - i != null - && (prev[i].value = [...slot]) - && slot.splice(0, slot.length, - ...prev - // remove nested slot handlers... - // XXX do we need this??? - .filter(function(e){ - return typeof(e) != 'function' - || e.slot != name }) ) } - /*/ text = text ? parser.expand(this, text ?? [], state) : text @@ -1365,18 +1329,15 @@ module.parser = { var slot = text } else { var slot = body ?? text } - var original = slot slots[name] = slot - //*/ + return hidden ? '' : Object.assign( function(st){ return ((st ?? state).slots ?? {})[name] - ?? original }, + ?? slot }, {slot: name}) }) }), - // XXX CONTENT... - //'content': ['slot'], // diff --git a/v3/pwiki/test/parser.js b/v3/pwiki/test/parser.js index 7c6ebd7..dc88846 100755 --- a/v3/pwiki/test/parser.js +++ b/v3/pwiki/test/parser.js @@ -54,25 +54,6 @@ test.Setups({ ...ins.map(function(e){ return e + 'third' }), 'third' ] }, - /* XXX CONTENT... - slot_content_empty: function(assert){ - return [ - '@slot(slot body="[[ ]]")', - '[[ ]]', - '[[ ]]' ] }, - slot_content_default: function(assert){ - return [ - '@slot(slot default body="[[ ]]")', - '[[ ]]', - '[[ default ]]' ] }, - slot_content_fill: function(assert){ - var ins = this.slot_content_default(assert) - var expect = ins.pop() - return [ - ...ins.map(function(i){ - return i +'@slot(slot value)' }), - expect.replace('default', 'value') ] }, - //*/ // XXX these are an alternative to ... slot_nested: function(assert){ @@ -84,43 +65,7 @@ test.Setups({ '[[ ]]@slot(slot value)', 'value' ] }, - /* XXX CONTENT... - // XXX the question with the next tow is: - // should body override or nest? - // ...both are logical but in either case the result should be - // consistent. - // - // XXX should the new body/content override or expand the original??? - slot_content_content: function(assert){ - var ins = this.slot_content_default(assert) - var expect = ins.pop() - return [ - ...ins.map(function(i){ - return i +'@slot(slot body="(( @content() ))")' }), - // XXX should this override the default above??? - //expect.replace('default', '(( default ))') ] }, - expect.replace('default', '(( ))') ] }, - slot_content_content_content: function(assert){ - var ins = this.slot_content_content(assert) - var expect = ins.pop() - return [ - ...ins.map(function(i){ - return i +'@slot(slot body="<< @content() >>")' }), - // XXX should this override the default above??? - //expect.replace('default', '(( default ))') ] }, - expect.replace('(( ))', '(( << >> ))') ] }, - // XXX if we are expanding (see above) why are we overriding here??? - slot_content_content_fill: function(assert){ - var ins = this.slot_content_content(assert) - var expect = ins.pop() - return [ - ...ins.map(function(i){ - return i +'@slot(slot value)' }), - expect.replace('(( ))', '(( value ))') ] }, - //expect.replace('(( ))', 'value') ] }, - // - - + /* XXX SHOWN_HIDDEN // XXX these need to be revised... // ...do we actually need hidden/shown??? //