I've installed markdown package on Meteor:
meteor add markdown
And test it successfully:
<body>
{{#markdown}}
#Hello world!#
{{/markdown}}
</body>
Ok!
Now I would like to import a markdown from a file and I had try in this way:
if (Meteor.isClient) {
Session.set("markdown_data","MDFile.md");
Template.myTemplate.helpers({
markdown_data: function() {
return Session.get("markdown_data");
}
});
}
And in html:
<body>
{{#markdown}}{{{markdown_data}}}{{/markdown}}
</body>
But nothing appears, neither on webpage or in web-console or terminal.
Where I'm wrong?
Update - working Code
if (Meteor.isClient) {
Markdown = new Mongo.Collection("markdown");
Template.myTemplate.helpers({
markdown_data: function() {
var markdown = Markdown.findOne();
return markdown && markdown.data;
}
});
}
if (Meteor.isServer) {
Markdown = new Mongo.Collection("markdown");
Meteor.startup(function () {
if(Markdown.find().count()===0){
Markdown.insert({
data: Assets.getText("teamProgramming.md")
});
}
});
}