Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2026-07-02 02:43:55 +03:00
parent d967a15a5d
commit e7dc0194ad
2 changed files with 16 additions and 3 deletions

View File

@ -677,6 +677,7 @@ module.BaseParser = {
// resolve stage II macros and merge results...
//
// XXX BUG: sync/async paths seem to diverge...
resolve: function(page, ast, state={}){
var that = this
ast = typeof(ast) != 'object' ?
@ -704,7 +705,12 @@ module.BaseParser = {
prev = '' }
if(args.length > 0){
elems.push(args.shift()) } } }
var unpack = function(elem){
// XXX
}
// XXX can ast be a promise???
// XXX elems can be unresolved -- need a merge strategy for them...
for(var elem of ast){
// nesting...
while(elem && elem.value){
@ -714,6 +720,11 @@ module.BaseParser = {
elem = elem(state) } }
if(elem == null){
continue }
// XXX do a delayed merge...
// ...but for this we need to also apply the rest of this iteration to the result...
if(elem.resolving){
console.log('!!!!!!!!!!!!!!!!!!!')
}
// atomic values...
if(typeof(elem) != 'object'){
merge(elem)
@ -725,11 +736,12 @@ module.BaseParser = {
continue }
// expand ast...
if(elem instanceof Array){
//merge(...this.resolve(page, elem, state))
// XXX this can containe promises...
merge(...this.resolve(page, elem, state))
continue }
// expand .body attribute...
if((elem.attrs ?? {}).body instanceof Array){
// XXX this can containe promises...
elem.attrs.body = this.resolve(page, elem.attrs.body, state) }
// nested macro with no value set -- skip...
if(this.macros[elem.name] instanceof Array){
@ -1527,7 +1539,6 @@ module.parser = {
delete state.include_stack
delete state.recursive }
// cache the final result...
// XXX wrap??
cache[src] = pages
return pages }

View File

@ -198,7 +198,7 @@ test.Setups({
return this.include(assert, '/page') },
include_include_page: function(assert){
return this.include(assert, '/includePage', 'Page') },
/* XXX
/* XXX parser.resolve(..) does not handle promises correctly yet...
include_async: function(assert){
return this.include(assert, '/async/page') },
//*/
@ -256,6 +256,8 @@ test.Tests({
'\n\t in: "'+ input +'"',
'\n\t out: "'+ res +'"',
'\n\texpected: "'+ expect +'"') } },
//asyncParse: async function(assert, state){
// return await this.parse(assert, state) },
})