Getting HTML from MongoDB for use in a template

I am new to Meteor.js and MongoDB, so this question may have an obvious solution that I am missing, but so far my searches have not displayed anything.

My first Meteor project is a very bare blog. In MongoDB, I have the following:

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() }); 

Then in blog.js I have:

  if (Meteor.isClient) { Meteor.subscribe("blog"); Template.posts.entry = function () { return Blog.find({}); }; } 

And finally, in my HTML, I have the following

  ... <div class="row"> {{> posts}} </div> ... <template name="posts"> <div class="span12"> {{#each entry}} {{author}} {{date}} {{title}} {{headerHTML}} {{bodyHTML}} {{/each}} </div> </template> 

When I have an application that executes the sections indicated by {{headerHTML}} and {{bodyHTML}}, it returns a literal string. This way you see the tags in the text. I want the string to be processed as HTML and displayed as such. So some text will be in bold, I may have links, etc. Any wisdom someone can give me?

I tried putting descriptors in various HTML tags (like <p>{{bodyHML}}</p> ) with no luck.

+7
source share
1 answer

Use the three brackets {{{ }}} to tell the meteor not to delete your HTML lines.

  {{{headerHTML}}} {{{bodyHTML}}} 
+14
source

All Articles