refactor: return value of Tag#render is no longer used

BREAKING CHANGE: Tag#render now returns void, use emitter argument
to write rendered html.
This commit is contained in:
harttle
2019-08-26 10:15:43 -05:00
committed by Jun Yang
parent 76019e9e18
commit 8028f82499
8 changed files with 26 additions and 38 deletions
+2 -3
View File
@@ -1,4 +1,4 @@
import { stringify, isFunction } from '../../util/underscore'
import { isFunction } from '../../util/underscore'
import { assert } from '../../util/assert'
import { Liquid } from '../../liquid'
import { Template } from '../../template/template'
@@ -26,8 +26,7 @@ export class Tag extends Template<TagToken> implements ITemplate {
public async render (ctx: Context, emitter: Emitter) {
const hash = await Hash.create(this.token.args, ctx)
const impl = this.impl
const html = isFunction(impl.render) ? stringify(await impl.render(ctx, hash, emitter)) : ''
html && emitter.write(html)
if (isFunction(impl.render)) await impl.render(ctx, hash, emitter)
}
public static register (name: string, tag: ITagImplOptions) {
Tag.impls[name] = tag