As I am learning how to use Blaze API, I am trying to create programmaticaly a View and render it to the DOM using Blaze.render. The return function of the view should return an html content.
However by doing so the htm is interpreted as text and whatever I tried I just could not succeed in doing so.
Is there a way to achieve this without using pre-defined templates ?
The code :
Template.myTemplate.onRendered(function () {
Session.set('foo','testfoo');
var id = document.getElementById("TestView");
var testView = Blaze.With(
function () {
return {
foo: Session.get('foo')
};
},
function () {
var data = Blaze.getData();
var html = "<div>foo value is " + data.foo + "</div>"
return html;
}
);
Blaze.render(testView, id);
});
The result is upadting reactively with Session.get(‘foo’); but I get the following in the web page :