forked from verdnatura/hedera-web
34 lines
669 B
JavaScript
34 lines
669 B
JavaScript
|
const Compiler = require('./compiler');
|
||
|
|
||
|
/**
|
||
|
* Compiles a @Text from text node.
|
||
|
*/
|
||
|
module.exports = new Class({
|
||
|
Extends: Compiler
|
||
|
|
||
|
,compile: function(builder, node, tagName) {
|
||
|
if (tagName && tagName != 't')
|
||
|
return null;
|
||
|
|
||
|
const text = node.textContent;
|
||
|
const context = {text};
|
||
|
|
||
|
if (tagName === 't') {
|
||
|
context.text = _(node.firstChild.textContent);
|
||
|
} else if (this.isExpr(text, true)) {
|
||
|
context.text = '';
|
||
|
this.compileExpr(context, null, text, true);
|
||
|
}
|
||
|
|
||
|
return context;
|
||
|
}
|
||
|
|
||
|
,instantiate: function(doc, context) {
|
||
|
return doc.createTextNode(context.text);
|
||
|
}
|
||
|
|
||
|
,setProperty(object, property, value) {
|
||
|
object.textContent = value;
|
||
|
}
|
||
|
});
|