Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Route Controller Styles Example #11

Closed
timkendall opened this issue Mar 9, 2016 · 6 comments
Closed

Add Route Controller Styles Example #11

timkendall opened this issue Mar 9, 2016 · 6 comments

Comments

@timkendall
Copy link
Contributor

We should add an example of using styles in route controllers. The README is unclear on this. In reality one needs to import styles into the controller module just like with components.

@dfreeman
Copy link
Member

You shouldn't ever need to explicitly import styles into a controller module – the only time that comes up is with components, and then only in addons because of the limitations with the resolver not being able to find those styles in the addon tree. There are acceptance tests for controller styles (both with and without an explicit controller module) that should be making sure this works.

@dfreeman
Copy link
Member

...unless you're writing a routable engine, in which case I guess you actually could have a controller in an addon. If that's what you're up to, you're treading plenty of new (and not-necessarily-production-ready) territory, so weird failures in this and other addons are a lot less shocking.

That would also explain why it appeared as if the initializer hadn't run in #10 – engines have their own isolated container/registry combo from their corresponding EngineInstance, so from the engine's perspective, that initializer didn't run.

Still, I'd only expect to see that particular error message in the nested component if your forgot to import the styles for that component, same as with a non-nested one. Is it possible that's the case?

@timkendall
Copy link
Contributor Author

That is indeed what I am doing :) In any case it looks like everything is working now (both nested components and routes). I probably did forget to import the style.

@dfreeman
Copy link
Member

I'll add a note to the README to mention engine controllers as well. That scenario hadn't actually occurred to me yet, so I'm glad folks are out there exercising this thing and finding these unanticipated cases – keep 'em coming! :)

@duro
Copy link

duro commented Jun 18, 2016

@dfreeman I came to this ticket thinking it would answer my question about applying a css module to a route template, but it did not.

I am not using pod style, for now, so I have an index route in /app/routes/index.js and it's corisponding template in /app/templates/index.hbs.

I tried adding a css module to both /app/styles/templates/index.css and /app/styles/routes/index.css, but anytime I try to use {{styles.class-name}} in the template, I get an empty response and no classname.

What might I be doing wrong? Documentation around using a css module with a route is pretty slim.

@dfreeman
Copy link
Member

dfreeman commented Jun 20, 2016

@duro The styles lookup process follows the same rules as everything else that goes through the resolver, so just like looking up template:index finds the file at app/templates/index.hbs and route:index looks at app/routes/index.js, styles:index will come from app/styles/index.css.

I'm planning a big overhaul of the documentation soon that gives better coverage of where to put things in different scenarios, as well as a number of "cookbook" examples demonstrating how to accomplish things at the macro level. Feedback like this is super useful as I'm planning what goes into that — thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants