I'm new to Meteor.js and MongoDB so this question might have an obvious solution that I am missing but so far my searches have turned up nothing.
My first Meteor project is a very bare-bones blog. In the 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 the app running the sections specified by {{headerHTML}} and {{bodyHTML}} return the literal string. So you see the tags in the text. What I want is for the string to be treated as HTML and displayed as such. So some text will be bolded, I could have links, etc... Any wisdom someone can throw my way?
I've tried putting the handlebars in various HTML tags (like <p>{{bodyHML}}</p>
) with no luck.
MongoDB NodeJS Driver APIs are used for the database server programming to read, add and delete data. The Web Server and the routes are defined using the ExpressJS web app framework. The browser client is built using HTML, CSS and Plain (Old) JavaScript.
You can use read operations to retrieve data from your MongoDB database. There are multiple types of read operations that access the data in different ways. If you want to request results based on a set of criteria from the existing set of data, you can use a find operation such as the find() or findOne() methods.
Use three brackets {{{ }}}
to tell meteor not to escape your html strings.
{{{headerHTML}}}
{{{bodyHTML}}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With