mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
chore(TypeScript): refactor objects into classes
fix: `Nil`(null, undefined) now renders as empty string change: `parser.parseValue()` renamed to `parser.parseOutput` change: registered tags/filters become static and shared across different liquid instances
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { stringify, create } from 'src/util/underscore'
|
||||
import { RenderBreakError, RenderError } from 'src/util/error'
|
||||
import assert from 'src/util/assert'
|
||||
import Scope from 'src/scope/scope'
|
||||
|
||||
export default class Render {
|
||||
async renderTemplates (templates, scope) {
|
||||
assert(scope, 'unable to evalTemplates: scope undefined')
|
||||
|
||||
let html = ''
|
||||
for (const tpl of templates) {
|
||||
try {
|
||||
html += await tpl.render(scope)
|
||||
} catch (e) {
|
||||
if (e instanceof RenderBreakError) {
|
||||
e.resolvedHTML = html
|
||||
throw e
|
||||
}
|
||||
throw e instanceof RenderError ? e : new RenderError(e, tpl)
|
||||
}
|
||||
}
|
||||
return html
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user