refactor: switch Context <-> Scope concepts

This commit is contained in:
harttle
2019-03-25 10:36:23 +08:00
parent 76345a64c3
commit 45e3c2bb8e
34 changed files with 272 additions and 272 deletions
+4 -4
View File
@@ -1,16 +1,16 @@
import { RenderError } from '../util/error'
import assert from '../util/assert'
import Scope from '../scope/scope'
import Context from '../context/context'
import ITemplate from '../template/itemplate'
export default class Render {
async renderTemplates (templates: ITemplate[], scope: Scope) {
assert(scope, 'unable to evalTemplates: scope undefined')
async renderTemplates (templates: ITemplate[], ctx: Context) {
assert(ctx, 'unable to evalTemplates: context undefined')
let html = ''
for (const tpl of templates) {
try {
html += await tpl.render(scope)
html += await tpl.render(ctx)
} catch (e) {
if (e.name === 'RenderBreakError') {
e.resolvedHTML = html