mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-16 16:11:39 +00:00
added optional include isolation...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6ad5cf4d1d
commit
f796ddf256
2
bootstrap.js
vendored
2
bootstrap.js
vendored
File diff suppressed because one or more lines are too long
@ -88,7 +88,7 @@ Example:
|
|||||||
- `[./_edit]` -- see the macro at the end of the page.
|
- `[./_edit]` -- see the macro at the end of the page.
|
||||||
|
|
||||||
|
|
||||||
### include (src text)
|
### include (src isolated text)
|
||||||
|
|
||||||
Include a page. The included page is rendered independently from current
|
Include a page. The included page is rendered independently from current
|
||||||
page and is inserted as-is in macro body.
|
page and is inserted as-is in macro body.
|
||||||
@ -99,6 +99,7 @@ but an html element body.
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- `src` -- path to source page.
|
- `src` -- path to source page.
|
||||||
|
- `isolated` -- prevent slots from included page from affecting the including page.
|
||||||
- `text` -- is used when recursive include is detected and ignored otherwise.
|
- `text` -- is used when recursive include is detected and ignored otherwise.
|
||||||
|
|
||||||
### source (src) / quote (src)
|
### source (src) / quote (src)
|
||||||
|
|||||||
32
wiki.js
32
wiki.js
@ -140,7 +140,7 @@ var macro = {
|
|||||||
// NOTE: included pages are rendered completely independently
|
// NOTE: included pages are rendered completely independently
|
||||||
// from the including page.
|
// from the including page.
|
||||||
include: Macro('Include page',
|
include: Macro('Include page',
|
||||||
['src', 'text'],
|
['src', 'isolated', 'text'],
|
||||||
function(context, elem, state){
|
function(context, elem, state){
|
||||||
var path = $(elem).attr('src')
|
var path = $(elem).attr('src')
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ var macro = {
|
|||||||
|
|
||||||
state = state || {}
|
state = state || {}
|
||||||
state.filters = state.filters || []
|
state.filters = state.filters || []
|
||||||
state.slots = state.slots || {}
|
//state.slots = state.slots || {}
|
||||||
state.include = state.include || []
|
state.include = state.include || []
|
||||||
state.seen = state.seen || []
|
state.seen = state.seen || []
|
||||||
|
|
||||||
@ -570,6 +570,7 @@ var macro = {
|
|||||||
var page = state.include.shift()
|
var page = state.include.shift()
|
||||||
var elem = $(page.shift())
|
var elem = $(page.shift())
|
||||||
page = page.pop()
|
page = page.pop()
|
||||||
|
var isolated = elem.attr('isolated') == 'true'
|
||||||
|
|
||||||
var seen = state.seen.slice()
|
var seen = state.seen.slice()
|
||||||
if(seen.indexOf(page.path) >= 0){
|
if(seen.indexOf(page.path) >= 0){
|
||||||
@ -586,15 +587,22 @@ var macro = {
|
|||||||
.parse(page,
|
.parse(page,
|
||||||
page.raw,
|
page.raw,
|
||||||
{
|
{
|
||||||
slots: state.slots,
|
//slots: !isolated ? state.slots : {},
|
||||||
templates: state.templates,
|
templates: state.templates,
|
||||||
seen: seen,
|
seen: seen,
|
||||||
},
|
},
|
||||||
true)))
|
!isolated)))
|
||||||
|
//true)))
|
||||||
.html()
|
.html()
|
||||||
}).join('\n')
|
}).join('\n')
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
console.log('>>>>',
|
||||||
|
context.path,
|
||||||
|
skip_post,
|
||||||
|
parsed.find(':not([isolated="true"]) slot').length,
|
||||||
|
parsed.find('[isolated="true"] slot').length)
|
||||||
|
|
||||||
// post processing...
|
// post processing...
|
||||||
if(!skip_post){
|
if(!skip_post){
|
||||||
// fill slots...
|
// fill slots...
|
||||||
@ -605,6 +613,14 @@ var macro = {
|
|||||||
parsed.find('slot')
|
parsed.find('slot')
|
||||||
.each(function(i, e){
|
.each(function(i, e){
|
||||||
e = $(e)
|
e = $(e)
|
||||||
|
|
||||||
|
// XXX not sure about this...
|
||||||
|
// ...check if it prevents correct slot parsing
|
||||||
|
// within an isolated include...
|
||||||
|
if(e.parents('[isolated="true"]').length > 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var n = e.attr('name')
|
var n = e.attr('name')
|
||||||
|
|
||||||
n in slots && e.detach()
|
n in slots && e.detach()
|
||||||
@ -615,6 +631,14 @@ var macro = {
|
|||||||
parsed.find('slot')
|
parsed.find('slot')
|
||||||
.each(function(i, e){
|
.each(function(i, e){
|
||||||
e = $(e)
|
e = $(e)
|
||||||
|
|
||||||
|
// XXX not sure about this...
|
||||||
|
// ...check if it prevents correct slot parsing
|
||||||
|
// within an isolated include...
|
||||||
|
if(e.parents('[isolated="true"]').length > 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var n = e.attr('name')
|
var n = e.attr('name')
|
||||||
|
|
||||||
e.replaceWith(slots[n])
|
e.replaceWith(slots[n])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user