【问题标题】:How to return html element from helper?如何从帮助程序返回 html 元素?
【发布时间】:2015-09-08 20:32:50
【问题描述】:

我需要添加 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";

【问题讨论】:

标签: javascript meteor handlebars.js meteor-helper


【解决方案1】:

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

{{{ title }}}

查看the docs了解更多信息。

【讨论】:

    猜你喜欢
    • 2011-09-12
    • 1970-01-01
    • 2011-01-20
    • 2014-06-04
    • 1970-01-01
    • 2014-12-06
    • 1970-01-01
    • 2023-03-26
    • 2013-03-21
    相关资源
    最近更新 更多