2018-12-12 11:04:00 -08:00
|
|
|
import './EditablePage.html';
|
|
|
|
|
|
|
|
|
|
let routeData = {
|
2019-01-07 16:53:54 -08:00
|
|
|
JrHighSummer: {name: "JrHighSummer"},
|
2018-12-12 11:04:00 -08:00
|
|
|
News: {name: "News"},
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
});
|