This is easily done using iron:router
layouts and applying a different class to each pages via routing.
First you need to define a main-layout such as :
<template name="mainLayout">
<!-- optional navbar yield -->
{{> yield region="navbar"}}
<div class="{{currentRouteName}}-page">
{{> yield}}
</div>
<!-- optional footer yield -->
{{> yield region="footer"}}
</template>
The currentRouteName
helper should look something like :
UI.registerHelper("currentRouteName",function(){
return Router.current()?Router.current().route.getName():"";
});
Then I recommend associating a RouteController
to your main-layout that will serve as the base class for all of your RouteController
s.
MainController=RouteController.extend({
layoutTemplate:"mainLayout",
// yield navbar and footer templates to navbar and footer regions respectively
yieldTemplates:{
"navbar":{
to:"navbar"
},
"footer":{
to:"footer"
}
}
});
Next you need to make sure that your routes use a controller which is derived from MainController
.
HomeController=MainController.extend({
template:"home"
});
Router.map(function(){
this.route("home",{
path:"/",
// optional, by default iron:router is smart enough to guess the controller name,
// by camel-casing the route name and appending "Controller"
controller:"HomeController"
});
});
So now your home route page is surrounded by a div having an "home-page" class, so you can style it in plain CSS (or better yet, using LESS) :
.home-page{
/* your css goes here */
}
If you define other routes, this will work seamlessly, just inherit from MainController
and you'll have a page with route-name-page class automatically.
Of course, you can use the same style for multiple pages, just specify it in CSS :
.home-page, .contact-page{
/* your css goes here */
}
You can do really nice stuff with layouts, I highly encourage using them.