mirror of
https://github.com/flynx/pWiki.git
synced 2025-11-03 12:30:07 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
416e3e7bde
commit
3810c4349c
@ -2015,44 +2015,45 @@ object.Constructor('Page', BasePage, {
|
|||||||
// XXX would be nice to be able to chain .awaitOrRun(..) calls instead
|
// XXX would be nice to be able to chain .awaitOrRun(..) calls instead
|
||||||
// of nesting them like here...
|
// of nesting them like here...
|
||||||
get text(){
|
get text(){
|
||||||
|
var that = this
|
||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
!this.strict
|
!that.strict
|
||||||
|| this.resolve(true),
|
|| that.resolve(true),
|
||||||
function(exists){
|
function(exists){
|
||||||
// strict mode -- break on non-existing pages...
|
// strict mode -- break on non-existing pages...
|
||||||
if(!exists){
|
if(!exists){
|
||||||
throw new Error('NOT FOUND ERROR: '+ this.location) }
|
throw new Error('NOT FOUND ERROR: '+ that.location) }
|
||||||
|
|
||||||
var path = pwpath.split(this.path)
|
var path = pwpath.split(that.path)
|
||||||
;(path.at(-1) ?? '')[0] == '_'
|
;(path.at(-1) ?? '')[0] == '_'
|
||||||
|| path.push(this.PAGE_TEMPLATE)
|
|| path.push(that.PAGE_TEMPLATE)
|
||||||
var tpl = pwpath.join(path)
|
var tpl = pwpath.join(path)
|
||||||
var tpl_name = path.pop()
|
var tpl_name = path.pop()
|
||||||
//var tpl_name = path.at(-1)
|
//var tpl_name = path.at(-1)
|
||||||
|
|
||||||
// get the template relative to the top most pattern...
|
// get the template relative to the top most pattern...
|
||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
this.get(tpl).find(true),
|
that.get(tpl).find(true),
|
||||||
function(tpl){
|
function(tpl){
|
||||||
if(!tpl){
|
if(!tpl){
|
||||||
console.warn('UNKNOWN RENDER TEMPLATE: '+ tpl_name)
|
console.warn('UNKNOWN RENDER TEMPLATE: '+ tpl_name)
|
||||||
return this.get(this.NOT_FOUND_TEMPLATE_ERROR).parse() }
|
return that.get(that.NOT_FOUND_TEMPLATE_ERROR).parse() }
|
||||||
|
|
||||||
var depends = this.depends = new Set([tpl])
|
var depends = that.depends = new Set([tpl])
|
||||||
// do the parse...
|
// do the parse...
|
||||||
// NOTE: we render the template in context of page...
|
// NOTE: we render the template in context of page...
|
||||||
return this
|
return that
|
||||||
// NOTE: this.path can both contain a template and not, this
|
// NOTE: that.path can both contain a template and not, this
|
||||||
// normalizes it to the path up to the template path...
|
// normalizes it to the path up to the template path...
|
||||||
.get(path, {args: this.args})
|
.get(path, {args: that.args})
|
||||||
.parse(
|
.parse(
|
||||||
this.get(
|
that.get(
|
||||||
'/'+tpl,
|
'/'+tpl,
|
||||||
{args: this.args}).raw,
|
{args: that.args}).raw,
|
||||||
{
|
{
|
||||||
depends,
|
depends,
|
||||||
renderer: this,
|
renderer: that,
|
||||||
}) }.bind(this)) }.bind(this)) },
|
}) }) }) },
|
||||||
/*/ // XXX ASYNC
|
/*/ // XXX ASYNC
|
||||||
get text(){ return (async function(){
|
get text(){ return (async function(){
|
||||||
// strict mode -- break on non-existing pages...
|
// strict mode -- break on non-existing pages...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user