ember-cli-cordova icon indicating copy to clipboard operation
ember-cli-cordova copied to clipboard

Different templates/controllers/views for different platforms

Open Globegitter opened this issue 10 years ago • 7 comments

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?

Globegitter avatar Nov 15 '14 13:11 Globegitter

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.

billybonks avatar Nov 17 '14 06:11 billybonks

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.. ?

jakecraige avatar Nov 17 '14 14:11 jakecraige

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

billybonks avatar Nov 17 '14 15:11 billybonks

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

jakecraige avatar Nov 17 '14 16:11 jakecraige

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.

runspired avatar Nov 18 '14 02:11 runspired

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.

mgenev avatar Feb 18 '15 19:02 mgenev

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.

Leooo avatar Nov 30 '15 18:11 Leooo