marko/compiler/ast/Else.js
Patrick Steele-Idem c386da875e Fixes #349 - Inline Marko template compilation support
Also changed how JavaScript code is generated
2016-08-19 10:50:28 -06:00

33 lines
648 B
JavaScript

'use strict';
var Node = require('./Node');
class Else extends Node {
constructor(def) {
super('Else');
this.body = this.makeContainer(def.body);
this.matched = false;
}
generateCode(codegen) {
if (!this.matched) {
codegen.addError('Unmatched else statement');
return;
}
this.body = codegen.generateCode(this.body);
return this;
}
writeCode(writer) {
var body = this.body;
writer.writeBlock(body);
writer.write('\n');
}
walk(walker) {
this.body = walker.walk(this.body);
}
}
module.exports = Else;