Create a gist now

Instantly share code, notes, and snippets.

Form Builder Example
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
model: Ember.Object.create({
name: 'Sergio',
bio: 'Ogro malvado achuchable',
lovesEmber: true
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{#form-for model as |f|}}
{{f.text-field "name"}}
{{f.text-area "bio"}}
{{f.checkbox "lovesEmber"}}
{{/form-for}}
<div class="info">
<p>{{model.name}}</p>
<p>{{model.bio}}</p>
{{#if model.lovesEmber}}
He does love Ember.js!
{{ else }}
He does not love Ember.js at all :(
{{/if}}
</div>
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
}).reopenClass({
positionalParams: ['object'],
});
<form>
{{yield (hash text-field=(component "my-text-field" object=object)
text-area =(component "my-text-area" object=object)
checkbox =(component "my-checkbox" object=object))}}
</form>
import Ember from 'ember';
export default Ember.Component.extend({
}).reopenClass({
positionalParams: ['propertyToEdit'],
});
<label>
{{propertyToEdit}}:
{{input type="checkbox" checked=(mut (get object propertyToEdit))}}
</label>
import Ember from 'ember';
export default Ember.Component.extend({
}).reopenClass({
positionalParams: ['propertyToEdit'],
});
<label>
{{propertyToEdit}}:<br/>
{{textarea value=(mut (get object propertyToEdit))}}
</label>
import Ember from 'ember';
export default Ember.Component.extend({
}).reopenClass({
positionalParams: ['propertyToEdit'],
});
<label>
{{propertyToEdit}}:
{{input type="text" value=(mut (get object propertyToEdit))}}
</label>
{
"version": "0.6.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment