Skip to content

Commit

Permalink
Merge pull request #5 from sir-dunxalot/develop
Browse files Browse the repository at this point in the history
Support attributes on {{input}}
  • Loading branch information
Duncan Walker committed Feb 27, 2015
2 parents 446018f + 0cb4413 commit 5dc1299
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-easy-form-extensions",
"version": "0.2.0",
"version": "0.2.1",
"description": "Extends Ember EasyForm into the view and controller layers of your Ember CLI app to provide easy event and action handling using mixins and components.",
"directories": {
"doc": "doc",
Expand Down
8 changes: 8 additions & 0 deletions tests/dummy/app/resources/posts/new/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
{{#form-controls legend='Write a new post'}}
{{input title}}
{{input description}}
{{input valueBinding=title}}
{{/form-controls}}

{{form-submission}}

{{/form-wrapper}}

<dl>
<dt>Title</dt>
<dd>{{title}}</dd>
<dt>Description</dt>
<dd>{{description}}</dd>
</dl>
26 changes: 21 additions & 5 deletions vendor/ember-easy-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Changed input helper (search for CHANGED) and removed precompiiled templates
/* WARNING: This file has been edited - it is different the original Easy Form source. Some functionality has been removed to work better with ember-easy-form-extensions and changes have been made for HTMLBars compatibility. */

// ==========================================================================
// Project: Ember EasyForm
Expand All @@ -12,6 +12,14 @@ var EasyFormShims;

EasyFormShims = {

callHelper: function(helperName, context, params, options, env) {
env = env ? env : options;

return Ember.Handlebars.helpers[helperName].helperFunction.call(
context, params, options.hash, options, options
);
},

getBinding: function(options, propertyName) {
propertyName += 'Binding';

Expand All @@ -25,9 +33,15 @@ var EasyFormShims;
},

viewHelper: function(context, View, options) {
return Ember.Handlebars.helpers.view.helperFunction.call(
context, [View], options.hash, options, options
);
return this.callHelper('view', context, [View], options);
},

emberInputHelper: function(context, options) {
var env = options;

env.helpers = Ember.Handlebars.helpers;

return this.callHelper('ember-input', context, [], options, env);
},
}

Expand Down Expand Up @@ -135,7 +149,9 @@ Ember.Handlebars.helpers['ember-input'] = Ember.Handlebars.helpers['input'];

Ember.Handlebars.registerHelper('input', function(property, options) {
if (arguments.length === 1) {
return Ember.Handlebars.helpers['ember-input'].call(this, arguments[0]);
options = property;

return EasyFormShims.emberInputHelper(this, options);
}

options = Ember.EasyForm.processOptions(property, options);
Expand Down

0 comments on commit 5dc1299

Please sign in to comment.