Skip to content

Commit

Permalink
intermediate work on renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
toddjordan committed Aug 18, 2016
1 parent efb6f0b commit 35ce4d7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion addon/components/dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ const DynamicForm = Ember.Component.extend({
let container = getOwner(this);
let config = container.resolveRegistration('config:environment');
if (config.dynamicForms && config.dynamicForms.renderer) {
Ember.Logger.debug('found renderer', config.dynamicForms.renderer);
renderer = container.lookup(`${config.dynamicForms.renderer}:dynamic-forms.renderers`);
} else {
renderer = container.lookup('alpaca:dynamic-forms.renderers');
}
this.set('_renderer', renderer);
}
renderer.render(this.get('renderSchema'), this.$());
renderer.render(this.get('renderSchema'), this);
},

didInsertElement() {
Expand Down
5 changes: 2 additions & 3 deletions addon/dynamic-forms/renderers/ember.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import Ember from 'ember';

export default Ember.Object.extend({
render(schema, component) {
Ember.Logger.debug('render!');
component.set('layout', Ember.computed(function () {
return Ember.HTMLBars.compile(`
{{#each fields as |field|}}
{{component field.type}}
{{/each}}
<b>hello world</b>
`);
}));
// iterate fields in schema
Expand Down
3 changes: 3 additions & 0 deletions app/dynamic-forms/renderers/ember.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Ember from 'ember-cli-dynamic-forms/dynamic-forms/renderers/ember';

export default Ember;
3 changes: 0 additions & 3 deletions app/renderers/alpaca.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ module.exports = {

},
isDevelopingAddon: function () {
return false;
return true;
}
};
4 changes: 4 additions & 0 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ module.exports = function(environment) {

}

ENV.dynamicForms = {
renderer: 'ember'
};

return ENV;
};

0 comments on commit 35ce4d7

Please sign in to comment.