2022-06-18 21:04:34 +00:00
|
|
|
const Compiler = require('./compiler');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compiles a @Text from text node.
|
|
|
|
*/
|
|
|
|
module.exports = new Class({
|
|
|
|
Extends: Compiler
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,compile(builder, node, tagName) {
|
2022-06-18 21:04:34 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,instantiate(doc, context) {
|
2022-06-18 21:04:34 +00:00
|
|
|
return doc.createTextNode(context.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
,setProperty(object, property, value) {
|
|
|
|
object.textContent = value;
|
|
|
|
}
|
|
|
|
});
|