From c05ef7db664a62781c74228e7f0bf4c0117b69ea Mon Sep 17 00:00:00 2001 From: l5oo00 Date: Wed, 13 Nov 2019 15:27:58 +0800 Subject: [PATCH] fix: remove when noDataOutput is true, fixes #21 --- src/target-js/compilers/anode-compiler.ts | 4 ++++ src/target-php/compilers/anode-compiler.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/target-js/compilers/anode-compiler.ts b/src/target-js/compilers/anode-compiler.ts index 8bfecc69..42501f49 100644 --- a/src/target-js/compilers/anode-compiler.ts +++ b/src/target-js/compilers/anode-compiler.ts @@ -58,7 +58,9 @@ export class ANodeCompiler { */ compileText (aNode: ANode, sourceBuffer) { if (aNode.textExpr.original) { + sourceBuffer.addRaw('if (!noDataOutput) {') sourceBuffer.joinString('') + sourceBuffer.addRaw('}') } if (aNode.textExpr.value != null) { @@ -68,7 +70,9 @@ export class ANodeCompiler { } if (aNode.textExpr.original) { + sourceBuffer.addRaw('if (!noDataOutput) {') sourceBuffer.joinString('') + sourceBuffer.addRaw('}') } } diff --git a/src/target-php/compilers/anode-compiler.ts b/src/target-php/compilers/anode-compiler.ts index a85407fa..eac77009 100644 --- a/src/target-php/compilers/anode-compiler.ts +++ b/src/target-php/compilers/anode-compiler.ts @@ -59,7 +59,10 @@ export class ANodeCompiler { */ compileText (aNode: ANode, emitter: PHPEmitter) { if (aNode.textExpr.original) { - emitter.bufferHTMLLiteral('') + emitter.writeIf('!$noDataOutput', () => { + emitter.bufferHTMLLiteral('') + emitter.clearStringLiteralBuffer() + }) } if (aNode.textExpr.value != null) { @@ -69,7 +72,10 @@ export class ANodeCompiler { } if (aNode.textExpr.original) { - emitter.bufferHTMLLiteral('') + emitter.writeIf('!$noDataOutput', () => { + emitter.bufferHTMLLiteral('') + emitter.clearStringLiteralBuffer() + }) } }