hedera-web/js/vn/compiler-text.js

51 lines
972 B
JavaScript

var Compiler = require ('./compiler');
/**
* Compiles a @Text from text node.
*/
module.exports = new Class
({
Extends: Compiler
,compile: function (builder, node, tagName)
{
if (!tagName)
{
var text = node.textContent;
if (/^\s*\\?[_|\\]/.test (text))
{
var prefix = text.match (/^\s*/)[0];
var suffix = text.match (/\s*$/)[0];
text = text.trim ();
text = prefix + this.translateValue(text) + suffix;
}
}
else if (tagName === 't')
var text = _(node.firstChild.textContent);
else
return null;
var context = {text: null};
if (this._interpoler.compile (context, null, text))
context.text = '';
else
context.text = text;
return context;
}
,instantiate: function (doc, context, scope)
{
return doc.createTextNode (context.text);
}
,setProperty: function (object, data, value)
{
object.textContent = value;
}
});