mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 08:31:38 +00:00
refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7a1956b760
commit
416e3e7bde
@ -2009,44 +2009,50 @@ object.Constructor('Page', BasePage, {
|
|||||||
// or render as any other page???
|
// or render as any other page???
|
||||||
// ...currently they are rendered in the context of the page and
|
// ...currently they are rendered in the context of the page and
|
||||||
// not in their own context...
|
// not in their own context...
|
||||||
/*/ XXX revise how we handle strict mode...
|
// XXX revise how we handle strict mode...
|
||||||
|
//
|
||||||
|
// XXX EXPERIMENTAL
|
||||||
|
// XXX would be nice to be able to chain .awaitOrRun(..) calls instead
|
||||||
|
// of nesting them like here...
|
||||||
get text(){
|
get text(){
|
||||||
// strict mode -- break on non-existing pages...
|
|
||||||
if(this.strict
|
|
||||||
// XXX
|
|
||||||
&& !await this.resolve(true)){
|
|
||||||
throw new Error('NOT FOUND ERROR: '+ this.location) }
|
|
||||||
|
|
||||||
var path = pwpath.split(this.path)
|
|
||||||
;(path.at(-1) ?? '')[0] == '_'
|
|
||||||
|| path.push(this.PAGE_TEMPLATE)
|
|
||||||
var tpl = pwpath.join(path)
|
|
||||||
var tpl_name = path.pop()
|
|
||||||
//var tpl_name = path.at(-1)
|
|
||||||
|
|
||||||
// get the template relative to the top most pattern...
|
|
||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
this.get(tpl).find(true),
|
!this.strict
|
||||||
function(tpl){
|
|| this.resolve(true),
|
||||||
if(!tpl){
|
function(exists){
|
||||||
console.warn('UNKNOWN RENDER TEMPLATE: '+ tpl_name)
|
// strict mode -- break on non-existing pages...
|
||||||
return this.get(this.NOT_FOUND_TEMPLATE_ERROR).parse() }
|
if(!exists){
|
||||||
|
throw new Error('NOT FOUND ERROR: '+ this.location) }
|
||||||
|
|
||||||
var depends = this.depends = new Set([tpl])
|
var path = pwpath.split(this.path)
|
||||||
// do the parse...
|
;(path.at(-1) ?? '')[0] == '_'
|
||||||
// NOTE: we render the template in context of page...
|
|| path.push(this.PAGE_TEMPLATE)
|
||||||
return that
|
var tpl = pwpath.join(path)
|
||||||
// NOTE: this.path can both contain a template and not, this
|
var tpl_name = path.pop()
|
||||||
// normalizes it to the path up to the template path...
|
//var tpl_name = path.at(-1)
|
||||||
.get(path, {args: this.args})
|
|
||||||
.parse(
|
// get the template relative to the top most pattern...
|
||||||
this.get(
|
return Promise.awaitOrRun(
|
||||||
'/'+tpl,
|
this.get(tpl).find(true),
|
||||||
{args: this.args}).raw,
|
function(tpl){
|
||||||
{
|
if(!tpl){
|
||||||
depends,
|
console.warn('UNKNOWN RENDER TEMPLATE: '+ tpl_name)
|
||||||
renderer: this,
|
return this.get(this.NOT_FOUND_TEMPLATE_ERROR).parse() }
|
||||||
}) }.bind(this)) },
|
|
||||||
|
var depends = this.depends = new Set([tpl])
|
||||||
|
// do the parse...
|
||||||
|
// NOTE: we render the template in context of page...
|
||||||
|
return this
|
||||||
|
// NOTE: this.path can both contain a template and not, this
|
||||||
|
// normalizes it to the path up to the template path...
|
||||||
|
.get(path, {args: this.args})
|
||||||
|
.parse(
|
||||||
|
this.get(
|
||||||
|
'/'+tpl,
|
||||||
|
{args: this.args}).raw,
|
||||||
|
{
|
||||||
|
depends,
|
||||||
|
renderer: this,
|
||||||
|
}) }.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