fix: address refactor comments

This commit is contained in:
Alex de Wergifosse
2020-12-16 10:20:10 +08:00
committed by Jun Yang
parent b8e4b3337b
commit 6a0ad102a8
8 changed files with 19 additions and 15 deletions
+7
View File
@@ -1,3 +1,5 @@
import { stringify, toValue } from '../util/underscore'
export class Emitter {
public html: any = '';
public break = false;
@@ -9,6 +11,11 @@ export class Emitter {
}
public write (html: any) {
if (this.keepOutputType === true) {
html = toValue(html)
} else {
html = stringify(toValue(html))
}
// This will only preserve the type if the value is isolated.
// I.E:
// {{ my-port }} -> 42
+4 -1
View File
@@ -4,7 +4,10 @@ import { Template } from '../template/template'
import { Emitter } from './emitter'
export class Render {
public * renderTemplates (templates: Template[], ctx: Context, emitter: Emitter): IterableIterator<any> {
public * renderTemplates (templates: Template[], ctx: Context, emitter?: Emitter): IterableIterator<any> {
if (!emitter) {
emitter = new Emitter(ctx.opts.keepOutputType)
}
for (const tpl of templates) {
try {
const html = yield tpl.render(ctx, emitter)