It was mentioned here at SFSE (and following the examples in the Lightning Developer Guide it seems to confirm) that right now hardcoded namespace references are quite common or even necessary. As far as I have understood this is going to be improved in future releases.
But are there right now any intermediate best practices, tricks or workarounds to avoid as many hardcoded references as possible to keep the our code portable and decoupled from specific orgs?
Any ideas welcome.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Support for relative/current namespace refs (c:blah) is available in Spring ’15 which will be hitting production soon. In markup you really do not have many options for minimizing the maintainable issue currently. We tried to get this in sooner but it was a bit tricker to layer on top of Aura than we had hoped.
FYI Spring ’15 also supports non-namespaced orgs 🙂
Method 2
This doesn’t help for the markup in the components, but if you need to reference the namespace in JavaScript you can use the following:
var ns = component.getDef().getDescriptor().getNamespace();
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0