简体   繁体   English

从Meteor Collection获取纯文本

[英]Getting plain text from Meteor Collection

I am working on making a blog with Meteor . 我正在与Meteor合作制作一个博客。 I have a text box that stores the title , a textarea that stores the content of my blog entry, and a "Submit" button. 我有一个存储title的文本框,一个存储我博客条目content的文本区域和一个“提交”按钮。 When I press the button I insert a title and content field into a Meteor Collection called Entries . 当我按下按钮时,我将titlecontent字段插入名为Entries的Meteor集合中。

In my HTML I use this template to render the blog entry: 在我的HTML中,我使用此模板来呈现博客条目:

<template name="cur_entries">
  {{#each entries}}
    <h2>{{title}}</h2>
    {{#markdown}}
{{content}}
    {{/markdown}}
    <hr>
  {{/each}}
</template>

And the Javascript for entries is: entries的Javascript是:

Template.cur_entries.entries = function() {
    return Entries.find({}, {sort: {date_created: -1}});
}

It only partly works. 它只是部分有效。 Leaving the title textbox blank, writing this markdown example in my content textarea, and pressing "Submit" results in this: title文本框留空,在我的content文本区域中写下此降价示例 ,然后按“提交”会导致以下结果:

在此输入图像描述

As you can see the ">" is preserved, and instead of having " s, there are &quot; s. I believe when text gets posted from the Meteor Collection, it is formatted to be "correctly" rendered by HTML, instead of just plain text. Unfortunately, in this case, I don't want this convenience. Is there any way to get just plain text from a Meteor Collection? 正如您所看到的那样,“>”被保留,而不是" s " ,而不是" s &quot; 。我相信当文本从Meteor Collection发布时,它被格式化为由HTML“正确”呈现,而不仅仅是纯文本。不幸的是,在这种情况下,我不希望这种方便。有没有办法从流星集合中获取纯文本?

Thanks. 谢谢。

try using 3 curly brackets to render them as HTML. 尝试使用3个大括号将它们渲染为HTML。

{{#markdown}}
  {{{content}}}
{{/markdown}}

提醒一下,{{#markdown}}现在仍然在鲨鱼分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM