100*_*nes 7 mongodb handlebars.js meteor
我是Meteor.js和MongoDB的新手,所以这个问题可能有一个明显的解决方案,我错过了,但到目前为止我的搜索没有任何结果.
我的第一个Meteor项目是一个非常简单的博客.在MongoDB中,我有以下内容:
Blog.insert({
author: "Name Here",
title: "Title Here",
headerHTML: "This is my <b>very</b> first blog post.",
bodyHTML: "What drives us to <em>solve</em> these types of problems?",
date: new Date()
});
Run Code Online (Sandbox Code Playgroud)
然后在blog.js我有:
if (Meteor.isClient) {
Meteor.subscribe("blog");
Template.posts.entry = function () {
return Blog.find({});
};
}
Run Code Online (Sandbox Code Playgroud)
最后在我的HTML中我有以下内容
...
<div class="row">
{{> posts}}
</div>
...
<template name="posts">
<div class="span12">
{{#each entry}}
{{author}}
{{date}}
{{title}}
{{headerHTML}}
{{bodyHTML}}
{{/each}}
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
当我让应用运行{{headerHTML}}和{{bodyHTML}}指定的部分时,返回文字字符串.所以你看到文本中的标签.我想要的是将字符串视为HTML并显示为这样.所以有些文字会加粗,我可以有链接等等......任何有智慧的人都可以抛弃我的方式?
我已经尝试将把手放在各种HTML标签(如<p>{{bodyHML}}</p>)中,但没有运气.
Aks*_*hat 14
使用三个括号{{{ }}}告诉meteor不要逃避你的html字符串.
{{{headerHTML}}}
{{{bodyHTML}}}
Run Code Online (Sandbox Code Playgroud)