mirror of
https://github.com/flynx/pWiki.git
synced 2026-07-14 04:20:58 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8b5f156816
commit
3829ce9764
@ -1287,9 +1287,10 @@ module.parser = {
|
||||
// are contained in, this will not lead to recursion.
|
||||
//
|
||||
// XXX do we actually need <content/>??
|
||||
// <slot slot>
|
||||
// <slot slot.content/>
|
||||
// </slot>
|
||||
// <slot slot>
|
||||
// <slot slot.content/>
|
||||
// </slot>
|
||||
// nesting slots basically does the same thing...
|
||||
// XXX do we show a slot with unfilled content???
|
||||
// ...what's the point in having <content>, 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 <content/>...
|
||||
for(prev of stack.reverse()){
|
||||
// get the first <content/>
|
||||
// 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'],
|
||||
|
||||
|
||||
//
|
||||
|
||||
@ -54,25 +54,6 @@ test.Setups({
|
||||
...ins.map(function(e){
|
||||
return e + '<slot slot>third</slot>' }),
|
||||
'third' ] },
|
||||
/* XXX CONTENT...
|
||||
slot_content_empty: function(assert){
|
||||
return [
|
||||
'@slot(slot body="[[ <content/> ]]")',
|
||||
'<slot slot>[[ <content/> ]]</slot>',
|
||||
'[[ ]]' ] },
|
||||
slot_content_default: function(assert){
|
||||
return [
|
||||
'@slot(slot default body="[[ <content/> ]]")',
|
||||
'<slot slot default>[[ <content/> ]]</slot>',
|
||||
'[[ 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 <content/>...
|
||||
slot_nested: function(assert){
|
||||
@ -84,43 +65,7 @@ test.Setups({
|
||||
'<slot slot>[[ <slot slot.content/> ]]</slot>@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???
|
||||
//
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user