如何从助手中获取 return html 元素?

How to return html element from helper?

我需要添加 html 元素表单助手。有办法吗?

模板:

<template name="Index">
 <div class="title"> {{title}} </div>
</template>

JS

Template.Index.helpers({
  title: function(){
    var testvariable = "Hello <b>World</b>";
    return testvariable;
  }
})

注意:以下方法可以正常工作。但在我的例子中,标题字符串是动态内容。

<div class="title"> Hello <b>{{title}}</b> </div>
var testvariable = "World";

您需要像这样使用三重大括号:

{{{ title }}}

查看 the docs 了解更多信息。