mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
fix: block.super with strictVariables, #806
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { Emitter, SimpleEmitter } from '../emitters'
|
||||
import { Drop } from './drop'
|
||||
|
||||
export class BlockDrop extends Drop {
|
||||
constructor (
|
||||
// the block render from layout template
|
||||
private superBlockRender: () => Iterable<any> = () => ''
|
||||
private superBlockRender: (emitter: Emitter) => IterableIterator<unknown> | string = () => ''
|
||||
) {
|
||||
super()
|
||||
}
|
||||
@@ -11,7 +12,9 @@ export class BlockDrop extends Drop {
|
||||
* Provide parent access in child block by
|
||||
* {{ block.super }}
|
||||
*/
|
||||
public super () {
|
||||
return this.superBlockRender()
|
||||
public * super (): IterableIterator<unknown> {
|
||||
const emitter = new SimpleEmitter()
|
||||
yield this.superBlockRender(emitter)
|
||||
return emitter.buffer
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -39,7 +39,11 @@ export default class extends Tag {
|
||||
ctx.pop()
|
||||
}
|
||||
return renderChild
|
||||
? (superBlock: BlockDrop, emitter: Emitter) => renderChild(new BlockDrop(() => renderCurrent(superBlock, emitter)), emitter)
|
||||
? (superBlock: BlockDrop, emitter: Emitter) => renderChild(
|
||||
new BlockDrop(
|
||||
(emitter: Emitter) => renderCurrent(superBlock, emitter)
|
||||
),
|
||||
emitter)
|
||||
: renderCurrent
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user