I am making a "multipage" app with meteor and would like to use different css files per page. Is this possible?
1 Answer
Meteor doesn't allow (currently) helpers inside the tag.
Rapid way: wrap all your content inside a div with an #id an then use stylus to wrap all the css rules ander that tag:
#myPagewrap1
#row
some: rule
#myPagewrap1
#row
some: rule
Long way: attach some dynamic css call to the .created method of your template.
Template.myPage.created = function(){
loadStyle("pathtostyle.css");
}
And your loadStyle function could be something like this: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
4 Comments
lardcanoe
Thanks! Went with this: Template.customPage.created = function () { $('head').append('<link rel="stylesheet" href="custom.css"/>'); };
rvr_jon
Make sure to add a condition to check if the stylesheet has already been added to the head, otherwise you'll have a bunch of duplicates.
hakan
this is not working. Meteor automatically pushes all the css files to the client.
Alveoli
@piedpiper put your CSS files in /public.
<style>might work