mirror of
https://github.com/flynx/pWiki.git
synced 2026-07-14 12:27:19 +00:00
moved recursion testing back -- diffrent macros may will need to control this differently...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b98e4ca5c0
commit
9341e45346
@ -1313,18 +1313,7 @@ module.parser = {
|
|||||||
// content handler...
|
// content handler...
|
||||||
handler ??=
|
handler ??=
|
||||||
function(page, body, path, text, state){
|
function(page, body, path, text, state){
|
||||||
return args.isolated ?
|
// check for recursion...
|
||||||
this.resolve(
|
|
||||||
page,
|
|
||||||
text,
|
|
||||||
args.isolated == 'partial' ?
|
|
||||||
serialize.partialDeepCopy(state)
|
|
||||||
: {})
|
|
||||||
: this.expand(page, text, state) }
|
|
||||||
|
|
||||||
var pageHandler =
|
|
||||||
function([path, text]){
|
|
||||||
// recursion...
|
|
||||||
// XXX for some reason this does not work for async...
|
// XXX for some reason this does not work for async...
|
||||||
// ...and works quite differently in tests and
|
// ...and works quite differently in tests and
|
||||||
// in console -- returns [object Object] in the
|
// in console -- returns [object Object] in the
|
||||||
@ -1336,24 +1325,39 @@ module.parser = {
|
|||||||
return that.expand(page, recursive, state) }
|
return that.expand(page, recursive, state) }
|
||||||
include_stack.push(path)
|
include_stack.push(path)
|
||||||
|
|
||||||
// XXX cache???
|
// XXX check cache???
|
||||||
|
|
||||||
// call the handler...
|
var res = args.isolated ?
|
||||||
|
this.resolve(
|
||||||
|
page,
|
||||||
|
text,
|
||||||
|
Object.assign(
|
||||||
|
args.isolated == 'partial' ?
|
||||||
|
serialize.partialDeepCopy(state)
|
||||||
|
: {},
|
||||||
|
{include_stack}))
|
||||||
|
: this.expand(page, text, state)
|
||||||
|
|
||||||
|
// handle recursion...
|
||||||
|
return Promise.awaitOrRun(
|
||||||
|
res,
|
||||||
|
function(){
|
||||||
|
state.include_stack.at(-1) == src
|
||||||
|
&& state.include_stack.pop()
|
||||||
|
// cleanup...
|
||||||
|
if(state.include_stack.length == 0){
|
||||||
|
delete state.include_stack
|
||||||
|
delete state.recursive }
|
||||||
|
|
||||||
|
return res }) }
|
||||||
|
|
||||||
|
var pageHandler =
|
||||||
|
function([path, text]){
|
||||||
|
// handle nested promises...
|
||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
text,
|
text,
|
||||||
function(text){
|
function(text){
|
||||||
return Promise.awaitOrRun(
|
return handler.call(that, page, body, path, text, state) }) }
|
||||||
handler.call(that, page, body, path, text, state),
|
|
||||||
function(res){
|
|
||||||
// recursion
|
|
||||||
state.include_stack.at(-1) == src
|
|
||||||
&& state.include_stack.pop()
|
|
||||||
// cleanup...
|
|
||||||
if(state.include_stack.length == 0){
|
|
||||||
delete state.include_stack
|
|
||||||
delete state.recursive }
|
|
||||||
|
|
||||||
return res }) }) }
|
|
||||||
|
|
||||||
// get and run things...
|
// get and run things...
|
||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user