Skip to content

Instantly share code, notes, and snippets.

@digilord
Created August 21, 2014 18:34
Show Gist options
  • Save digilord/cd85e2b58f90c47c7770 to your computer and use it in GitHub Desktop.
Save digilord/cd85e2b58f90c47c7770 to your computer and use it in GitHub Desktop.
// server
Meteor.publish('pages', function () {
return Pages.find({});
});
Pages.allow({
update: function () {
return true;
}
});
// shared
Pages = new Meteor.Collection('pages');
// Meteor.methods({
// getPageTitle: function (pageIndex) {
// var title;
// title = Pages.find({
// pageIndex: pageIndex
// }, {
// fields: {
// title: 1
// }
// }
// ).fetch()[0];
// return title.title;
// }
// });
// client
Template.header.helpers({
title: function () {
// Whenever the session variable pageIndex changes the title will be updated.
_pageIndex = Session.get('pageIndex')
_doc = Pages.findOne({pageIndex: _pageIndex});
if(_doc){
return _doc.title
}
}
});
// template
<template name="header">
<h1>{{title}}</h1>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment