Skip to content

Instantly share code, notes, and snippets.

@digilord
Last active January 4, 2016 01:39
Show Gist options
  • Save digilord/8550148 to your computer and use it in GitHub Desktop.
Save digilord/8550148 to your computer and use it in GitHub Desktop.
// helper for all templates.
Handlebars.registerHelper("site", function(){
return Site.findOne({}); // Missing the query for the collection here. Need to narrow it down.
});
Handlebars.registerHelper("siteTheme", function(){
site = Site.findOne({}); // See comment on line 3.
if(typeof site == 'object'){
Session.set('theme', site.theme);
}
});
//theme = this._theme; // Help here.
//Session.set("theme", theme);
// Add theme class to html
siteTheme0 = function(){
$('html').addClass('theme0');
};
siteTheme1 = function(){
$('html').addClass('theme1');
};
siteTheme2 = function(){
$('html').addClass('theme2');
};
siteTheme3 = function(){
$('html').addClass('theme3');
};
// Change theme on change to db
Deps.autorun(function (c) {
if (Session.equals("theme", "1")){
siteTheme1();
}
else if (Session.equals("theme", "2")){
siteTheme2();
}
else if (Session.equals("theme", "3")){
siteTheme3();
}
else {
Session.set("theme", "0");
siteTheme0();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment