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

39 lines
784 B
JavaScript
Raw Normal View History

2017-10-20 12:06:16 +00:00
var Compiler = require ('./compiler');
/**
* Compiles a @HTML.TextNode 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;
return {text: text};
}
2017-10-20 17:09:06 +00:00
,instantiate: function (doc, context, scope)
2017-10-20 12:06:16 +00:00
{
2017-10-20 17:09:06 +00:00
return doc.createTextNode (scope.interpolate (context.text));
2017-10-20 12:06:16 +00:00
}
});