mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
37 lines
660 B
JavaScript
37 lines
660 B
JavaScript
'use strict';
|
|
|
|
const Node = require('./Node');
|
|
|
|
function _isMultilineComment(comment) {
|
|
return comment && comment.indexOf('\n') !== -1;
|
|
}
|
|
|
|
class Comment extends Node {
|
|
constructor(def) {
|
|
super('Comment');
|
|
|
|
const comment = def.comment;
|
|
|
|
if (_isMultilineComment(comment)) {
|
|
this.comment = `/*\n${comment}\n*/`;
|
|
} else {
|
|
this.comment = `// ${comment}`;
|
|
}
|
|
}
|
|
|
|
generateCode(codegen) {
|
|
return this;
|
|
}
|
|
|
|
writeCode(writer) {
|
|
var name = this.comment;
|
|
writer.write(name);
|
|
}
|
|
|
|
toString() {
|
|
return this.comment;
|
|
}
|
|
}
|
|
|
|
module.exports = Comment;
|