0

我这里有个小问题。当我尝试从 mongodb 设置标签文本时,我的
标签变成了 <br>。

//我的流星方法

Meteor.methods({
  addEventDetails : function(title, details) {
    details=details.replace('\n', "<br>");
    eventDetails.insert({'title': title, 'details': details});
  } 
});

//我的模板函数

Template.detailsboard.evt = function(){
    return eventDetails.findOne({});
  }

//我的模板

<template name="detailsboard">
    <div class="block">
        <div class="navbar navbar-inner block-header">

            <div class="pull-left"><i class="icon-bookmark"></i><span class="block-header-title">Event Details</span></div>
            <div class="pull-right searchbar"></div>
            <!-- <div class="pull-right"><span class="badge badge-warning">View More</span></div> -->
        </div>
        <!-- /block header-->
        <!-- block content -->
        <div class="block-content-details collapse in">
            <ol class="stream-items" id="stream-items-id">
                <a class="logo-details" href="/"></a>
                <div class="row-fluid" style="padding:10%">
                    <div class="span12">
                    <label class="text-inverse details-title">{{evt.title}}</label>
                    **//problem here**
                    <p class="text-inverse details-content">this.html({{evt.details}})</p>

                    </div>
                </div>
            </ol>
        </div>
        <!-- /block content -->
    </div>
    <!-- block header -->
</template>
4

1 回答 1

1

使用三重胡子{{{evt.details}}},因为默认情况下 Handlebars(或最初的 Mustache)会转义 HTML。

于 2013-06-11T16:48:38.880 回答