ember-cli-cordova
ember-cli-cordova copied to clipboard
Different templates/controllers/views for different platforms
The idea was mentioned in this issue: https://github.com/poetic/ember-cli-cordova/issues/32, to add support for platform specific files such as my-template.android.hbs
or my-controller.ios.js
.
I think that would be a great addition to have, because sometimes you have to apply some fixes or workarounds that are dependent on only one platform but it can make the overall template/controller quite cluttered up. What do you think?
By cluttered up you mean making those fixes without this functionality, i agree with that.
If you where worried about to many .platform.ext files you could libraryfi them as ember-addons.
overall i am keen for this functionality.
I like the idea and would support getting this into here, though I've yet to find much of a use for it personally.
I've had success with ember-cli-cordova-utils and doing a {{#if device.isAndroid}}
or a this.device.get('isAndroid')
to handle specific cases. Most thinks I have to change per platform are pretty minor.
Out of curiosity, what sort of case do you need to completely swap the entire template/controller/etc.. ?
My used case, would be sharing the controllers mixins etc between mobile and desktop, but probably having different templates, but that could be done via library, then sharing it in 2 repos
Desktop and mobile does seem useful. We have been considering making some apps that do this sort of thing and this could definitely help if that's the case
Our app is desktop, mobile, and android and there are a few special considerations based on platform. Currently desktop v. tablet v. phone is done by utilizing a base repository as an ember-addon and then adding in the platform dependent alterations. It would be interesting, but perhaps a little too aggressive to start combining all of these concerns into a single repo.
I also would like this separation possible. We often end up writing whole different templates for mobile (in the browser) to avoid too much logic in a huge template which would have both behaviors... Right now we use the resolver to make the choice for the appropriate template. Would be pretty neat if the build knows what to do in a cordova deployment's case.
It would be very useful to have dedicated templates for mobile versions: see Rails' views_mobile/
, views_tablet/
folders, which are parsed first in case there is a different template for mobile versions (with a fallback to the views/
folder when there is no template overriding it).
If anyone knows how to add this kind of behaviour in Ember-CLI I would be grateful.