10

I am making a "multipage" app with meteor and would like to use different css files per page. Is this possible?

4
  • I guess <style> might work Commented Mar 12, 2013 at 19:19
  • 1
    Downvoters: please explain why you downvoted this question! Commented Mar 13, 2013 at 2:11
  • 1
    I actually upvoted this its a good question, Meteor doesn't use conventional style pages, rather in a router. Commented Mar 13, 2013 at 11:33
  • I upvoted too. I'm here to look for solutions to include different js scripts for multipage app. Commented Jun 3, 2013 at 10:03

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! Went with this: Template.customPage.created = function () { $('head').append('<link rel="stylesheet" href="custom.css"/>'); };
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.
this is not working. Meteor automatically pushes all the css files to the client.
@piedpiper put your CSS files in /public.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.