我正在使用Node.js的IMAP模块来解析IMAP电子邮件的正文。我可以将正文作为原始HTML数据返回给我,但这包括标签和其他不必要的数据。我想要输入的文字(删除所有div,样式等)
这是我当前正在使用的代码:
openInbox(function(err, box) {
if (err) throw err;
var f = imap.seq.fetch(box.messages.total + ':*', { bodies: ['HEADER.FIELDS (FROM)','TEXT'] });
f.on('message', function(msg, seqno) {
console.log('Message #%d', seqno);
var prefix = '(#' + seqno + ') ';
msg.on('body', function(stream, info) {
if (info.which === 'TEXT')
console.log(prefix + '\n\nBody [%s] found, %d total bytes\n\n\n', inspect(info.which), info.size);
var buffer = '', count = 0;
stream.on('data', function(chunk) {
count += chunk.length;
buffer += chunk.toString('utf8');
if (info.which === 'TEXT')
console.log(prefix + 'Body [%s] (%d/%d)', inspect(info.which), …Run Code Online (Sandbox Code Playgroud) 如何返回字段的标准渲染?
(function () {
var readonlyFiledContext = {};
readonlyFiledContext.Templates = {};
readonlyFiledContext.Templates.Fields = {
// Apply the new rendering for Age field on Edit forms
"Title": {
"EditForm": FieldTemplate
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(FiledContext);
})();
function FieldTemplate(ctx) {
return ;
}
}
Run Code Online (Sandbox Code Playgroud)
这取决于我要呈现字段的值。当该值不为null时,将其设为fancy;当该值等于“ null”时,则像标准渲染一样进行渲染。如何在此代码段中返回标准字段呈现?
感谢您的帮助Stefan