tweaking pattern path rendering...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-08-03 14:13:23 +03:00
parent 13d3388950
commit 6c5b088dd5

View File

@ -1537,11 +1537,13 @@ object.Constructor('Page', BasePage, {
text = null } text = null }
state = state ?? {} state = state ?? {}
text = text text = text
?? await this.raw ?? await this.each()
return text instanceof Array ? return text instanceof Array ?
Promise.iter(text) Promise.iter(text)
.map(function(text){ .map(function(text){
return that.__parser__.parse(that, text, state) }) return text instanceof Page ?
that.__parser__.parse(text, null, state)
: that.__parser__.parse(that, text, state) })
: this.__parser__.parse(this, text, state) }, : this.__parser__.parse(this, text, state) },
// true if page has an array value but is not a pattern page... // true if page has an array value but is not a pattern page...
@ -1561,6 +1563,28 @@ object.Constructor('Page', BasePage, {
// NOTE: when matching multiple pages this will return a list... // NOTE: when matching multiple pages this will return a list...
get raw(){ return (async function(){ get raw(){ return (async function(){
var that = this var that = this
var pages = await this.each()
.map(async function(page){
var data = await page.data
return (
// action...
typeof(data) == 'function' ?
data.call(page)
: data.text ) })
if(pages.length == 0){
var msg = (this.PAGE_NOT_FOUND
|| module.PAGE_NOT_FOUND)
.replace(/\$PATH/, this.path)
if(this.PAGE_NOT_FOUND){
return msg }
throw new Error(msg) }
return this.isPattern ?
pages
: pages[0] }).call(this) },
/*/
var data = await this.data var data = await this.data
// no data... // no data...
// NOTE: if we hit this it means that nothing was resolved, // NOTE: if we hit this it means that nothing was resolved,
@ -1587,6 +1611,7 @@ object.Constructor('Page', BasePage, {
: d.text }) : d.text })
.flat() .flat()
: data.text )}).call(this) }, : data.text )}).call(this) },
//*/
set raw(value){ set raw(value){
this.__update__({text: value}) }, this.__update__({text: value}) },
//this.onTextUpdate(value) }, //this.onTextUpdate(value) },