Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE ember-htmlbars-scoped-helpers] #10244

Closed

Commits on Jan 18, 2015

  1. [FEATURE ember-htmlbars-scoped-helpers]

    Allows locally scoped helpers to be used in a components layout (or in
    the template block if using block params).
    
    ----
    
    Local Helpers Example:
    
    ```javascript
    // app/components/x-foo.js
    
    import Ember from "ember";
    
    var makeBoundHelper = Ember.HTMLBars.makeBoundHelper;
    
    export default Ember.Component.extend({
      capitalize: makeBoundHelper(function(params) {
        return params[0].toUpperCase();
      })
    });
    ```
    
    ```handlebars
    {{! app/templates/components/x-foo.hbs }}
    
    {{capitalize 'blahzorz'}} === BLAHZORZ
    ```
    
    ----
    
    Block Params Example:
    
    ```javascript
    // app/components/form-for.js
    
    import Ember from "ember";
    import FormForInput from "./helpers/input";
    
    var makeViewHelper = Ember.HTMLBars.makeViewHelper;
    
    export default Ember.Component.extend({
      formHelpers: {
        input: makeViewHelper(FormForInput)
      }
    });
    ```
    
    ```handlebars
    {{! app/templates/components/form-for.hbs }}
    
    {{yield formHelpers}}
    ```
    
    ```handlebars
    {{! app/templates/post/new.hbs }}
    
    {{#form-for as |f|}}
      {{f.input label="Title" value=model.title}}
    {{/form-for}}
    ```
    rwjblue committed Jan 18, 2015
    Configuration menu
    Copy the full SHA
    838d599 View commit details
    Browse the repository at this point in the history