35 lines
888 B
JavaScript
35 lines
888 B
JavaScript
import './EditablePage.html';
|
|
|
|
let routeData = {
|
|
JrHighSummer: {name: "JrHighSummer"},
|
|
News: {name: "News"},
|
|
SecondChance: {name: "SecondChance"},
|
|
ImportantDates: {name: "Dates"},
|
|
CurrentBoard: {name: "Board"}
|
|
};
|
|
|
|
Tracker.autorun(function() {
|
|
Meteor.subscribe("pages");
|
|
});
|
|
|
|
Template.EditablePage.onCreated(function() {
|
|
let template = this;
|
|
|
|
this.pageName = new ReactiveVar();
|
|
|
|
Tracker.autorun(function() {
|
|
if(routeData[FlowRouter.getRouteName()]) {
|
|
//Save the page's name (indexes the page HTML in the collection) to the reactive variable so that all the content changes automatically.
|
|
template.pageName.set(routeData[FlowRouter.getRouteName()].name);
|
|
}
|
|
});
|
|
});
|
|
|
|
Template.EditablePage.helpers({
|
|
editableHTML: function() {
|
|
let doc = Meteor.collections.Pages.findOne({name: Template.instance().pageName.get()});
|
|
|
|
return doc === undefined ? "" : doc.html;
|
|
}
|
|
});
|