mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
fix: break/continue omitting output before them, #123
BREAKING CHANGE: remove default export, now should be used like import
{Liquid} from 'liquidjs'
This commit is contained in:
+6
-13
@@ -1,22 +1,15 @@
|
||||
import { RenderError } from '../util/error'
|
||||
import assert from '../util/assert'
|
||||
import Context from '../context/context'
|
||||
import ITemplate from '../template/itemplate'
|
||||
import { Context } from '../context/context'
|
||||
import { ITemplate } from '../template/itemplate'
|
||||
import { Emitter } from './emitter'
|
||||
|
||||
export default class Render {
|
||||
public async renderTemplates (templates: ITemplate[], ctx: Context) {
|
||||
assert(ctx, 'unable to evalTemplates: context undefined')
|
||||
|
||||
const emitter = new Emitter()
|
||||
export class Render {
|
||||
public async renderTemplates (templates: ITemplate[], ctx: Context, emitter = new Emitter()) {
|
||||
for (const tpl of templates) {
|
||||
try {
|
||||
emitter.write(await tpl.render(ctx, emitter))
|
||||
await tpl.render(ctx, emitter)
|
||||
} catch (e) {
|
||||
if (e.name === 'RenderBreakError') {
|
||||
e.resolvedHTML = emitter.html
|
||||
throw e
|
||||
}
|
||||
if (e.name === 'RenderBreakError') throw e
|
||||
throw e.name === 'RenderError' ? e : new RenderError(e, tpl)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user