Further to my previous post about obtaining data from objects on the server using Meteor.call I'd like to know how this same data can render HTML once similar object data from the server is received. Here is a simple example:
/server/svr.js
Meteor.methods({
test: function(text) {
var result = {};
result.foo = "<em>" + text + "</em>";
result.bar = text;
return result;
}
});
/client/del.js
Meteor.call('test', "Hello World - May 2012", function(err, data) {
if (err)
console.log(err);
Session.set('q', data);
});
Template.hello.greeting = function() {
return Session.get('q').foo;
};
When I run this code in the standard meteor app I see on the browser window:
Hello World!
<em>Hello World - May 2012</em>
Ideally I'd like the session variable containing the html code to have rendered that which was passed into it (in the simple example above - making the second line italicised when output to the browser). How do I go about accomplishing this?
Thanks in advance for any help!
Use {{{greeting}}}
instead of {{greeting}}
to make sure it isn't escaped.
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