ember-css-modules
ember-css-modules copied to clipboard
change local-class attribute name
Hi, I've just skimmed through the code and it seems like currently there's no way to override the local-class attribute name on a per project basis.
We're looking for what local-class provides but would ideally like a more concise attribute namee or ideally just class to replace default behaviour. if we could do this for the rare time we need to bring back default class output it would be nice to have that specified by another attribute, like global-class.
Out of curiosity, is there limitations around custom naming, hence the design or could this be something simple to expose as an option?
That's a neat idea. That's especially useful with tools like Emmett, which cannot be configured.
Since the local-class stuff is just a template transform that changes local-class="x y z" to class={{local-class "x y z"}}, this should be doable.
Do you think a switch between local-class / class and class / global-class would be sufficient instead of allowing an arbitrary attribute name?
I would personally see this as a arbitrary attribute to suit the project, at least as something to override the default. The switch example is a good use case and I can see alot of people using this for new projects. Though can't go past the flexibility of the former though.
On a side note, our projects pod structure had stylesheets as 'style.ext' instead of 'styles.ext'. This seemed to be an easy name change in code to get it working. I could be missing a bunch of edgecases with this but maybe another option that could be exposed.
I definitely see where you're coming from, but I'm hesitant to add additional configuration/complexity to the core addon at this point, particularly in terms of what it would mean for the overhead in terms of documentation and support.
The good news, though, is that this would be about as easy to implement in a standalone addon as it would in the core — you could write a template transform that runs ahead of ember-css-modules to translate class into local-class and global-class into class (or whatever attribute names you like), and then users could opt into the behavior just by additionally installing your addon 🙂
thanks for the follow up guys